1000
|
It is possible to search for an item ( inside the Editor ), case insensitive

with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('DropDownList')) as EXGRIDLib_TLB.Column).Editor do
begin
EditType := EXGRIDLib_TLB.DropDownListType;
AddItem(1,'One',Null);
AddItem(2,'Two',Null);
AddItem(3,'Three',Null);
end;
with Items do
begin
AddItem(Grid1.Columns.Item[OleVariant(0)].Editor.FindItem['>ONE']);
AddItem(Grid1.Columns.Item[OleVariant(0)].Editor.FindItem['>ThRee']);
AddItem(Grid1.Columns.Item[OleVariant(0)].Editor.FindItem['ONE']);
AddItem(Grid1.Columns.Item[OleVariant(0)].Editor.FindItem['>tWo']);
end;
EndUpdate();
end
|
999
|
The text after the BR-tag is in same line as the text before the BR-tag (entire column)

with Grid1 do
begin
BeginUpdate();
DrawGridLines := EXGRIDLib_TLB.exHLines;
with (IUnknown(Columns.Add('Default')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
Def[EXGRIDLib_TLB.exCellSingleLine] := OleVariant(False);
end;
with Items do
begin
AddItem('This is the first line.<br>This is the second line.');
AddItem('This is the first line.<br>This is the second line.');
AddItem('This is the first line.<br>This is the second line.');
end;
EndUpdate();
end
|
998
|
The text after the BR-tag is in same line as the text before the BR-tag (individual)

with Grid1 do
begin
BeginUpdate();
DrawGridLines := EXGRIDLib_TLB.exHLines;
Columns.Add('Default');
with Items do
begin
CellValueFormat[OleVariant(AddItem('This is the first line.<br>This is the second line.')),OleVariant(0)] := EXGRIDLib_TLB.exHTML;
h := AddItem('<b>This is the first line.<br>This is the second line.</b>');
CellValueFormat[OleVariant(h),OleVariant(0)] := EXGRIDLib_TLB.exHTML;
CellSingleLine[OleVariant(h),OleVariant(0)] := EXGRIDLib_TLB.exCaptionWordWrap;
CellValueFormat[OleVariant(AddItem('This is the first line.<br>This is the second line.')),OleVariant(0)] := EXGRIDLib_TLB.exHTML;
end;
EndUpdate();
end
|
997
|
Can I disable an item once the user selects a new value into a different item

// Change event - Occurs when the user changes the cell's content.
procedure TForm1.Grid1Change(ASender: TObject; Item : HITEM;ColIndex : Integer;var NewValue : OleVariant);
begin
with Grid1 do
begin
with Items do
begin
EnableItem[ItemByIndex[1]] := False;
end;
end
end;
with Grid1 do
begin
FreezeEvents(True);
BeginUpdate();
ScrollBySingleLine := True;
DrawGridLines := EXGRIDLib_TLB.exRowLines;
Columns.Add('Q');
Columns.Add('A');
with Items do
begin
h1 := AddItem('What''s your gender?');
with CellEditor[OleVariant(h1),OleVariant(1)] do
begin
EditType := EXGRIDLib_TLB.DropDownListType;
AddItem(1,'Male',Null);
AddItem(0,'Female',Null);
end;
CellValue[OleVariant(h1),OleVariant(1)] := OleVariant(1);
h2 := AddItem('What''s pet name?');
CellValue[OleVariant(h2),OleVariant(1)] := 'This is my pet favorite long long long name, that shoul break the line in multiple pieces';
CellSingleLine[OleVariant(h2),OleVariant(1)] := EXGRIDLib_TLB.exCaptionWordWrap;
end;
EndUpdate();
FreezeEvents(False);
end
|
996
|
How can I get a row expanded / enlarged to fit the cell's text (entire column)

with Grid1 do
begin
BeginUpdate();
ScrollBySingleLine := True;
DrawGridLines := EXGRIDLib_TLB.exRowLines;
Columns.Add('Q');
with (IUnknown(Columns.Add('A')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellSingleLine] := OleVariant(False);
with Editor do
begin
EditType := EXGRIDLib_TLB.MemoType;
Appearance := EXGRIDLib_TLB.SingleApp;
end;
end;
with Items do
begin
h1 := AddItem('What''s name?');
CellValue[OleVariant(h1),OleVariant(1)] := 'This is my pet favorite long long long name, that shoul break the line in multiple pieces';
h2 := AddItem('What''s your pet name?');
CellValue[OleVariant(h2),OleVariant(1)] := 'This is my pet favorite long long long name, that shoul break the line in multiple pieces';
end;
EndUpdate();
end
|
995
|
How can I get a row expanded / enlarged to fit the cell's text (individual cell)

with Grid1 do
begin
BeginUpdate();
ScrollBySingleLine := True;
DrawGridLines := EXGRIDLib_TLB.exRowLines;
Columns.Add('Q');
Columns.Add('A');
with Items do
begin
h1 := AddItem('What''s name?');
CellValue[OleVariant(h1),OleVariant(1)] := 'This is my pet favorite long long long name, that shoul break the line in multiple pieces';
h2 := AddItem('What''s your pet name?');
with CellEditor[OleVariant(h2),OleVariant(1)] do
begin
EditType := EXGRIDLib_TLB.MemoType;
Appearance := EXGRIDLib_TLB.SingleApp;
end;
CellValue[OleVariant(h2),OleVariant(1)] := 'This is my pet favorite long long long name, that shoul break the line in multiple pieces';
CellSingleLine[OleVariant(h2),OleVariant(1)] := EXGRIDLib_TLB.exCaptionWordWrap;
end;
EndUpdate();
end
|
994
|
InsertControlItem / UserEditor / A2X:

with Grid1 do
begin
BeginUpdate();
BackColor := RGB(240,240,240);
ConditionalFormats.Add('1 = 1',Null).Bold := True;
(IUnknown(Columns.Add('Type')) as EXGRIDLib_TLB.Column).Alignment := EXGRIDLib_TLB.RightAlignment;
with Items do
begin
h := AddItem('1. A ProgID such as "MSCAL.Calendar.7"');
ItemDivider[h] := 0;
hX := InsertControlItem(0,'MSCAL.Calendar','');
(IUnknown(ItemObject[hX]) as MSACAL_TLB.Calendar).BackColor := $ffffff;
h := AddItem('2. A CLSID such as "{0036F83C-D892-4B7B-AA0B-BEDD8D16A738}"');
ItemDivider[h] := 0;
hX := InsertControlItem(0,'{0036F83C-D892-4B7B-AA0B-BEDD8D16A738}','');
h := AddItem('3. A URL such as "http://www.exontrol.com"');
ItemDivider[h] := 0;
hX := InsertControlItem(0,'http://www.exontrol.com','');
h := AddItem('4. A reference to an Active document such as "file://\\Documents\MyDoc.doc"');
ItemDivider[h] := 0;
hX := InsertControlItem(0,'file://C:\empesting.xml','');
h := AddItem('5.A fragment of HTML such as "MSHTML:<HTML><BODY>This is a line of text</BODY></HTML>"');
ItemDivider[h] := 0;
hX := InsertControlItem(0,'MSHTML:<HTML><BODY>This is a <b>line of</b> text</BODY></HTML>','');
ItemHeight[hX] := 56;
h := AddItem('6.Anything, if it is preffixed by "A2X:"');
ItemDivider[h] := 0;
hX := InsertControlItem(0,'A2X:TOC24.Toc24Ctrl.1','');
end;
EndUpdate();
end
|
993
|
How do I add a RichTextBox editor
// UserEditorOleEvent event - Occurs when an user editor fires an event.
procedure TForm1.Grid1UserEditorOleEvent(ASender: TObject; Object : IDispatch;Ev : IOleEvent;var CloseEditor : WordBool;Item : HITEM;ColIndex : Integer);
begin
with Grid1 do
begin
OutputDebugString( Ev );
end
end;
with Grid1 do
begin
BeginUpdate();
DrawGridLines := EXGRIDLib_TLB.exAllLines;
DefaultItemHeight := 32;
with (IUnknown(Columns.Add('RICHTEXT')) as EXGRIDLib_TLB.Column).Editor do
begin
EditType := EXGRIDLib_TLB.UserEditorType;
UserEditor('RICHTEXT.RichtextCtrl','');
with (IUnknown(UserEditorObject) as RichTextLib_TLB.RichTextBox) do
begin
AutoVerbMenu := True;
TextRTF := '{\rtf1\ansi{\fonttbl\f0\fswiss Helvetica;}\f0\pard\r\nThis is some {\b bold} text.\par\r\n}';
end;
end;
with Items do
begin
AddItem('RICHTEXT.RichtextCtrl');
end;
EndUpdate();
end
|
992
|
Is it possible to trap a double-click event on a specific cell and when that happens, to set the cell to a specific value
// DblClick event - Occurs when the user dblclk the left mouse button over an object.
procedure TForm1.Grid1DblClick(ASender: TObject; Shift : Smallint;X : Integer;Y : Integer);
begin
with Grid1 do
begin
h := ItemFromPoint[-1,-1,c,hit];
OutputDebugString( Items.CellValue[OleVariant(h),OleVariant(c)] );
end
end;
with Grid1 do
begin
BeginUpdate();
HeaderAppearance := EXGRIDLib_TLB.Etched;
DrawGridLines := EXGRIDLib_TLB.exRowLines;
Columns.Add('C1');
Columns.Add('C2');
with Items do
begin
CellValue[OleVariant(AddItem('Item 1')),OleVariant(1)] := 'Item 2';
CellValue[OleVariant(AddItem('Item 3')),OleVariant(1)] := 'Item 4';
CellValue[OleVariant(AddItem('Item 5')),OleVariant(1)] := 'Item 6';
end;
EndUpdate();
end
|
991
|
How can I display dates in DD/MM/YYYY format

with Grid1 do
begin
BeginUpdate();
ScrollBySingleLine := False;
Columns.Add('Date');
with Items do
begin
ItemDivider[AddItem('Different Date Formats')] := 0;
FormatCell[OleVariant(AddItem('12/1/1971')),OleVariant(0)] := '((shortdateF(value) mid 4) left 2) + `/` + (shortdateF (value) left 2) + `/` + (shortdateF (value) right 4)';
FormatCell[OleVariant(AddItem('12/1/1971')),OleVariant(0)] := '(1 array (0:=(shortdateF(value) split `/`))) + `/` + (0 array (=:0) ) + `/` + (2 array (=:0) )';
FormatCell[OleVariant(AddItem('12/1/1971')),OleVariant(0)] := '((`0` + day(value) ) right 2) + `/` + ((`0` + month(value) ) right 2) + `/` + year(value)';
FormatCell[OleVariant(AddItem('12/1/1971')),OleVariant(0)] := 'day(value) + `/` + month(value) + `/` + year(value)';
FormatCell[OleVariant(AddItem('12/1/1971')),OleVariant(0)] := 'year(value) + ` - ` + day(value) + ` - ` + month(value)';
h := AddItem('12/1/1971');
ItemHeight[h] := 24;
CellValueFormat[OleVariant(h),OleVariant(0)] := EXGRIDLib_TLB.exHTML;
FormatCell[OleVariant(h),OleVariant(0)] := '`<b>` + year(value) + `</b><off -4> ` + day(value) + ` - ` + month(value)';
ItemDivider[AddItem('Predefined Date Formats')] := 0;
FormatCell[OleVariant(AddItem('12/1/1971')),OleVariant(0)] := 'value';
FormatCell[OleVariant(AddItem('12/1/1971')),OleVariant(0)] := 'shortdateF(value)';
FormatCell[OleVariant(AddItem('12/1/1971')),OleVariant(0)] := 'shortdate(value)';
FormatCell[OleVariant(AddItem('12/1/1971')),OleVariant(0)] := 'longdate(value)';
end;
EndUpdate();
end
|
990
|
I have noticed that the column gets resized once I release the mouse. I have a column that displays multiple-lines cells, and the text gets wrapped only when user releases the mouse. Is it possible to get resized contiguously as I had before
with Grid1 do
begin
BeginUpdate();
ScrollBySingleLine := False;
DrawGridLines := EXGRIDLib_TLB.exVLines;
ColumnsAllowSizing := True;
(IUnknown(Columns.Add('Column A (cont)')) as EXGRIDLib_TLB.Column).Def[EXGRIDLib_TLB.exColumnResizeContiguously] := OleVariant(True);
Columns.Add('Column 1');
(IUnknown(Columns.Add('Column B (cont)')) as EXGRIDLib_TLB.Column).Def[EXGRIDLib_TLB.exColumnResizeContiguously] := OleVariant(True);
Columns.Add('Column 2');
EndUpdate();
end
|
989
|
How do I get the column from cursor, when it hovers the empty portion of the items section
// MouseMove event - Occurs when the user moves the mouse.
procedure TForm1.Grid1MouseMove(ASender: TObject; Button : Smallint;Shift : Smallint;X : Integer;Y : Integer);
begin
with Grid1 do
begin
i := ItemFromPoint[0,-1,c,hit];
OutputDebugString( 'Column' );
OutputDebugString( c );
end
end;
with Grid1 do
begin
BeginUpdate();
DrawGridLines := EXGRIDLib_TLB.exVLines;
Columns.Add('Column 0');
Columns.Add('Column 1');
Columns.Add('Column 2');
EndUpdate();
end
|
988
|
How do I add items once the user clicks the empty area
// Click event - Occurs when the user presses and then releases the left mouse button over the grid control.
procedure TForm1.Grid1Click(ASender: TObject; );
begin
with Grid1 do
begin
i := ItemFromPoint[0,-1,c,hit];
with Items do
begin
CellValue[OleVariant(AddItem(OleVariant(i))),OleVariant(1)] := OleVariant(c);
end;
end
end;
with Grid1 do
begin
BeginUpdate();
Columns.Add('Number of Items to Add');
Columns.Add('Click on Column');
EndUpdate();
end
|
987
|
Is there any option to stop events
// AddItem event - Occurs after a new Item has been inserted to Items collection.
procedure TForm1.Grid1AddItem(ASender: TObject; Item : HITEM);
begin
with Grid1 do
begin
OutputDebugString( 'AddItem event is fired only if FreezeEvents(False) is called' );
end
end;
with Grid1 do
begin
FreezeEvents(True);
BeginUpdate();
DefaultItemHeight := 24;
Columns.Add('Task');
with Items do
begin
h1 := AddItem('Task 1');
h2 := AddItem('Task 2');
end;
EndUpdate();
FreezeEvents(False);
end
|
986
|
How can I include the child items, when a filter is applied

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := True;
ContinueColumnScroll := False;
MarkSearchColumn := False;
SearchColumnIndex := 1;
Indent := 16;
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
FilterBarPromptVisible := EXGRIDLib_TLB.exFilterBarPromptVisible;
FilterBarPromptPattern := 'Nancy';
FilterInclude := EXGRIDLib_TLB.exItemsWithChilds;
with Columns do
begin
(IUnknown(Add('Name')) as EXGRIDLib_TLB.Column).Width := 96;
(IUnknown(Add('Title')) as EXGRIDLib_TLB.Column).Width := 96;
Add('City');
end;
with Items do
begin
h0 := AddItem('Nancy Davolio');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Representative';
CellValue[OleVariant(h0),OleVariant(2)] := 'Seattle';
h0 := InsertItem(h0,Null,'Andrew Fuller');
CellValue[OleVariant(h0),OleVariant(1)] := 'Vice President, Sales';
CellValue[OleVariant(h0),OleVariant(2)] := 'Tacoma';
h0 := InsertItem(h0,Null,'Michael Suyama');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Representative';
CellValue[OleVariant(h0),OleVariant(2)] := 'London';
h0 := AddItem('Janet Leverling');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Representative';
CellValue[OleVariant(h0),OleVariant(2)] := 'Kirkland';
h0 := InsertItem(h0,Null,'Margaret Peacock');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Representative';
CellValue[OleVariant(h0),OleVariant(2)] := 'Redmond';
ExpandItem[0] := True;
end;
ApplyFilter();
EndUpdate();
end
|
985
|
How do I prevent changing the cell's state ( check-box state )
// CellStateChanging event - Fired before cell's state is about to be changed.
procedure TForm1.Grid1CellStateChanging(ASender: TObject; Item : HITEM;ColIndex : Integer;var NewState : Integer);
begin
with Grid1 do
begin
with Items do
begin
NewState := CellState[OleVariant(Item),OleVariant(ColIndex)];
end;
end
end;
with Grid1 do
begin
BeginUpdate();
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
with (IUnknown(Columns.Add('P1')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
PartialCheck := True;
end;
with (IUnknown(Columns.Add('P2')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
PartialCheck := True;
end;
with Items do
begin
h := AddItem('Root');
InsertItem(h,Null,'Child 1');
InsertItem(h,Null,'Child 2');
ExpandItem[h] := True;
end;
EndUpdate();
end
|
984
|
How do I get sorted the column as string, numeric, date, date and time. Also how can it be applied to drop down filter panel

with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('Date')) as EXGRIDLib_TLB.Column) do
begin
SortType := EXGRIDLib_TLB.SortDate;
DisplayFilterButton := True;
DisplayFilterPattern := False;
DisplayFilterDate := True;
FilterList := Integer(EXGRIDLib_TLB.exShowFocusItem) Or Integer(EXGRIDLib_TLB.exShowCheckBox) Or Integer(EXGRIDLib_TLB.exSortItemsDesc);
end;
with (IUnknown(Columns.Add('DateTime')) as EXGRIDLib_TLB.Column) do
begin
SortType := EXGRIDLib_TLB.SortDateTime;
DisplayFilterButton := True;
DisplayFilterPattern := False;
FilterList := Integer(EXGRIDLib_TLB.exShowFocusItem) Or Integer(EXGRIDLib_TLB.exShowCheckBox) Or Integer(EXGRIDLib_TLB.exSortItemsDesc);
end;
with (IUnknown(Columns.Add('Time')) as EXGRIDLib_TLB.Column) do
begin
SortType := EXGRIDLib_TLB.SortTime;
DisplayFilterButton := True;
DisplayFilterPattern := False;
FilterList := Integer(EXGRIDLib_TLB.exShowFocusItem) Or Integer(EXGRIDLib_TLB.exShowCheckBox) Or Integer(EXGRIDLib_TLB.exSortItemsDesc);
FormatColumn := 'time(value)';
end;
with (IUnknown(Columns.Add('Numeric')) as EXGRIDLib_TLB.Column) do
begin
SortType := EXGRIDLib_TLB.SortNumeric;
DisplayFilterButton := True;
FilterList := Integer(EXGRIDLib_TLB.exShowFocusItem) Or Integer(EXGRIDLib_TLB.exShowCheckBox) Or Integer(EXGRIDLib_TLB.exSortItemsDesc);
end;
with (IUnknown(Columns.Add('String')) as EXGRIDLib_TLB.Column) do
begin
DisplayFilterButton := True;
FilterList := Integer(EXGRIDLib_TLB.exShowFocusItem) Or Integer(EXGRIDLib_TLB.exShowCheckBox) Or Integer(EXGRIDLib_TLB.exSortItemsDesc);
end;
with Items do
begin
h := AddItem('1/27/2010');
CellValue[OleVariant(h),OleVariant(1)] := '1/27/2010 10:00:00 AM';
CellValue[OleVariant(h),OleVariant(2)] := CellValue[OleVariant(h),OleVariant(1)];
CellValue[OleVariant(h),OleVariant(3)] := OleVariant(1);
CellValue[OleVariant(h),OleVariant(4)] := CellValue[OleVariant(h),OleVariant(3)];
h := AddItem('1/27/2011');
CellValue[OleVariant(h),OleVariant(1)] := '1/27/2011 9:00:00 AM';
CellValue[OleVariant(h),OleVariant(2)] := CellValue[OleVariant(h),OleVariant(1)];
CellValue[OleVariant(h),OleVariant(3)] := OleVariant(11);
CellValue[OleVariant(h),OleVariant(4)] := CellValue[OleVariant(h),OleVariant(3)];
h := AddItem('11/2/2010');
CellValue[OleVariant(h),OleVariant(1)] := '11/2/2010 9:00:00 AM';
CellValue[OleVariant(h),OleVariant(2)] := CellValue[OleVariant(h),OleVariant(1)];
CellValue[OleVariant(h),OleVariant(3)] := OleVariant(2);
CellValue[OleVariant(h),OleVariant(4)] := CellValue[OleVariant(h),OleVariant(3)];
end;
Columns.Item['DateTime'].DisplayFilterDate := False;
EndUpdate();
end
|
983
|
I am using Layout property to sort multiple columns at once. The problem is that all items get expanded. How do I prevent that

with Grid1 do
begin
BeginUpdate();
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
with (IUnknown(Columns.Add('P1')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
PartialCheck := True;
end;
with (IUnknown(Columns.Add('P2')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
PartialCheck := True;
FormatColumn := '1 index ``';
end;
with Items do
begin
h := AddItem('Root');
InsertItem(h,Null,'Child A');
InsertItem(h,Null,'Child B');
InsertItem(h,Null,'Child A');
InsertItem(h,Null,'Child B');
AddItem('Root');
AddItem('Root');
end;
SingleSort := False;
Layout := 'multiplesort="C0:1 C1:2";collapse=""';
EndUpdate();
end
|
982
|
How do I find the cell's type, or what the cell holds

with Grid1 do
begin
BeginUpdate();
DrawGridLines := EXGRIDLib_TLB.exRowLines;
with Columns do
begin
(IUnknown(Add('Value')) as EXGRIDLib_TLB.Column).Width := 24;
(IUnknown(Add('Type')) as EXGRIDLib_TLB.Column).FormatColumn := 'type(%0)';
(IUnknown(Add('TypeAsString')) as EXGRIDLib_TLB.Column).FormatColumn := '(0 := type(%0)) array (`empty`, `null`, `short`, `long`, `float`, `double`, `currency`, `date`, `string`, `object`, `error`, `bo' +
'olean`, `variant`, `any`, `reserved`, `decimal`, `char`, `byte`, `unsigned short`, `unsigned long`, `long on 64 bits`)';
(IUnknown(Add('Length')) as EXGRIDLib_TLB.Column).FormatColumn := 'len(%0)';
end;
with Items do
begin
AddItem(Null);
AddItem('');
CellValue[OleVariant(.AddItem(Null)),OleVariant(0)] := (IUnknown(Grid1.DefaultInterface) as EXGRIDLib_TLB.Grid);
CellValue[OleVariant(AddItem(Null)),OleVariant(0)] := OleVariant(True);
CellValue[OleVariant(AddItem(Null)),OleVariant(0)] := OleVariant(-1);
CellValue[OleVariant(AddItem(Null)),OleVariant(0)] := OleVariant(-1);
CellValue[OleVariant(AddItem(Null)),OleVariant(0)] := '1/1/2001';
end;
EndUpdate();
end
|
981
|
How can I get ride / hide the image being dragged by OLE Drag and Drop
// OLEStartDrag event - Occurs when the OLEDrag method is called.
procedure TForm1.Grid1OLEStartDrag(ASender: TObject; Data : IExDataObject;var AllowedEffects : Integer);
begin
// Data.SetData("data to drag")
with Grid1 do
begin
AllowedEffects := 1;
end
end;
with Grid1 do
begin
OLEDropMode := EXGRIDLib_TLB.exOLEDropManual;
Background[EXGRIDLib_TLB.exDragDropAfter] := $ffffff;
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
Columns.Add('Default');
with Items do
begin
h := AddItem('Root');
InsertItem(h,Null,'Child 1');
InsertItem(h,Null,'Child 2');
ExpandItem[h] := True;
end;
end
|
980
|
The ReadOnly property does not prevent changing the column's check-box (sample 2)

with Grid1 do
begin
BeginUpdate();
ShowFocusRect := False;
with (IUnknown(Columns.Add('C1')) as EXGRIDLib_TLB.Column) do
begin
AllowSizing := False;
Width := 18;
Editor.EditType := EXGRIDLib_TLB.CheckValueType;
end;
Columns.Add('C2');
with Items do
begin
CellValue[OleVariant(AddItem(OleVariant(0))),OleVariant(1)] := 'Item 1';
CellValue[OleVariant(AddItem(OleVariant(-1))),OleVariant(1)] := 'Item 2';
CellValue[OleVariant(AddItem(OleVariant(0))),OleVariant(1)] := 'Item 3';
end;
ReadOnly := EXGRIDLib_TLB.exReadOnly;
Columns.Item[OleVariant(0)].Editor.Option[EXGRIDLib_TLB.exCheckValue2] := OleVariant(2);
EndUpdate();
end
|
979
|
The ReadOnly property does not prevent changing the column's check-box (sample 1)

with Grid1 do
begin
BeginUpdate();
ShowFocusRect := False;
with (IUnknown(Columns.Add('C1')) as EXGRIDLib_TLB.Column) do
begin
AllowSizing := False;
Width := 18;
with Editor do
begin
EditType := EXGRIDLib_TLB.CheckValueType;
Option[EXGRIDLib_TLB.exCheckValue2] := OleVariant(1);
end;
end;
Columns.Add('C2');
with Items do
begin
CellValue[OleVariant(AddItem(OleVariant(0))),OleVariant(1)] := 'Item 1';
CellValue[OleVariant(AddItem(OleVariant(-1))),OleVariant(1)] := 'Item 2';
CellValue[OleVariant(AddItem(OleVariant(0))),OleVariant(1)] := 'Item 3';
end;
ReadOnly := EXGRIDLib_TLB.exReadOnly;
EndUpdate();
end
|
978
|
How can I export checked items only

with Grid1 do
begin
BeginUpdate();
with Columns do
begin
(IUnknown(Add('C1')) as EXGRIDLib_TLB.Column).Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
(IUnknown(Add('C2')) as EXGRIDLib_TLB.Column).FormatColumn := '1 index `A-Z`';
(IUnknown(Add('C3')) as EXGRIDLib_TLB.Column).FormatColumn := '100 index ``';
end;
with Items do
begin
AddItem('Item 1');
CellState[OleVariant(AddItem('Item 2')),Null] := 1;
CellState[OleVariant(AddItem('Item 3')),Null] := 1;
end;
EndUpdate();
OutputDebugString( 'Export CSV Checked Items Only:' );
OutputDebugString( Export('','chk') );
end
|
977
|
How can I export a hidden column

with Grid1 do
begin
BeginUpdate();
with Columns do
begin
Add('C1');
with (IUnknown(Add('C2')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '1 index `A-Z`';
Visible := False;
end;
with (IUnknown(Add('C3')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '100 index ``';
Visible := False;
end;
end;
with Items do
begin
AddItem('Item 1');
AddItem('Item 2');
AddItem('Item 3');
end;
EndUpdate();
OutputDebugString( 'Export CSV Hidden Columns (1,2):' );
OutputDebugString( Export('','|1,2') );
end
|
976
|
I'm trying to use automatic numbering of the outline. How can I have A, B, C for root items, 1, 2, 3 for the sub-items, and a, b, c for sub-sub-items (sample 3)

with Grid1 do
begin
BeginUpdate();
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
DrawGridLines := EXGRIDLib_TLB.exRowLines;
AutoDrag := EXGRIDLib_TLB.exAutoDragPositionAny;
HasLines := EXGRIDLib_TLB.exSolidLine;
Indent := 16;
MarkSearchColumn := False;
with Columns do
begin
with (IUnknown(Add('')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
FormatColumn := '((1:=(0 :=(1 rpos ''.|A-Z||a-z|'')) rfind `.`) < 0 ? `<b>` + =:0 + `` : (=:0 mid (1 + 1 + =:1) ) + `)` ) + ` ` + value';
end;
end;
with Items do
begin
h := AddItem('Root');
InsertItem(h,Null,'Child');
hChild := InsertItem(h,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(h,Null,'Child');
ExpandItem[0] := True;
h := AddItem('Root');
InsertItem(h,Null,'Child');
hChild := InsertItem(h,Null,'Child');
CellState[OleVariant(hChild),OleVariant(0)] := 1;
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(h,Null,'Child');
end;
EndUpdate();
end
|
975
|
I'm trying to use automatic numbering of the outline. How can I have A, B, C for root items, 1, 2, 3 for the sub-items, and a, b, c for sub-sub-items (sample 2)

with Grid1 do
begin
BeginUpdate();
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
GridLineColor := RGB(190,190,190);
DrawGridLines := EXGRIDLib_TLB.exRowLines;
AutoDrag := EXGRIDLib_TLB.exAutoDragPositionAny;
HasLines := EXGRIDLib_TLB.exSolidLine;
Indent := 16;
with Columns do
begin
Add('Default');
with (IUnknown(Add('')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
Def[EXGRIDLib_TLB.exCellPaddingRight] := OleVariant(4);
AllowSizing := False;
Width := 36;
Position := 0;
FormatColumn := '(1:=(0 :=(1 rpos ''.|A-Z||a-z|'')) rfind `.`) < 0 ? `<b>` + =:0 : (`............` left 2 * (=:0 count `.`)) + (=:0 mid (1 + 1 + =:' +
'1) ) ';
end;
end;
with Items do
begin
h := AddItem('Root');
InsertItem(h,Null,'Child');
hChild := InsertItem(h,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(h,Null,'Child');
ExpandItem[0] := True;
h := AddItem('Root');
InsertItem(h,Null,'Child');
hChild := InsertItem(h,Null,'Child');
CellState[OleVariant(hChild),OleVariant(0)] := 1;
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(h,Null,'Child');
end;
EndUpdate();
end
|
974
|
I'm trying to use automatic numbering of the outline. How can I have A, B, C for root items, 1, 2, 3 for the sub-items, and a, b, c for sub-sub-items (sample 1)

with Grid1 do
begin
BeginUpdate();
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
DrawGridLines := EXGRIDLib_TLB.exRowLines;
AutoDrag := EXGRIDLib_TLB.exAutoDragPositionAny;
HasLines := EXGRIDLib_TLB.exSolidLine;
Indent := 16;
with Columns do
begin
Add('Default');
with (IUnknown(Add('')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
Def[EXGRIDLib_TLB.exCellPaddingRight] := OleVariant(4);
Alignment := EXGRIDLib_TLB.RightAlignment;
AllowSizing := False;
Width := 24;
Position := 0;
FormatColumn := '(1:=(0 :=(1 rpos ''.|A-Z||a-z|'')) rfind `.`) < 0 ? `<b>` + =:0 : `<i>` + (=:0 mid (1 + 1 + =:1) ) ';
end;
end;
with Items do
begin
h := AddItem('Root');
InsertItem(h,Null,'Child');
hChild := InsertItem(h,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(h,Null,'Child');
ExpandItem[0] := True;
h := AddItem('Root');
InsertItem(h,Null,'Child');
hChild := InsertItem(h,Null,'Child');
CellState[OleVariant(hChild),OleVariant(0)] := 1;
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(hChild,Null,'Child');
InsertItem(h,Null,'Child');
end;
EndUpdate();
end
|
973
|
How can I programmatically group by columns, without having the control's sort bar visible

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
SortBarHeight := 0;
SortBarVisible := True;
SortBarCaption := 'Drag a <b>column</b> header here to group by that column.';
AllowGroupBy := True;
Layout := 'multiplesort="C1:2"';
EndUpdate();
end
|
972
|
How do I perform my own sort

// Sort event - Fired when the control sorts a column.
procedure TForm1.Grid1Sort(ASender: TObject; );
begin
with Grid1 do
begin
OutputDebugString( 'Sort' );
with Items do
begin
ItemPosition[ItemByIndex[1]] := 0;
ItemPosition[ItemByIndex[0]] := 1;
end;
end
end;
with Grid1 do
begin
BeginUpdate();
SingleSort := False;
SortOnClick := EXGRIDLib_TLB.exUserSort;
with Columns do
begin
(IUnknown(Add('Index')) as EXGRIDLib_TLB.Column).FormatColumn := '0 index ``';
Add('Data 1');
Add('Data 2');
end;
with Items do
begin
h := AddItem(OleVariant(0));
CellValue[OleVariant(h),OleVariant(1)] := OleVariant(2);
CellValue[OleVariant(h),OleVariant(2)] := OleVariant(3);
h := AddItem(OleVariant(4));
CellValue[OleVariant(h),OleVariant(1)] := OleVariant(5);
CellValue[OleVariant(h),OleVariant(2)] := OleVariant(6);
h := AddItem(OleVariant(7));
CellValue[OleVariant(h),OleVariant(1)] := OleVariant(8);
CellValue[OleVariant(h),OleVariant(2)] := OleVariant(9);
end;
Layout := 'multiplesort="C1:1 C2:2"';
EndUpdate();
end
|
971
|
Is it possible to have a different alignment for parts of the cell's caption

with Grid1 do
begin
BeginUpdate();
TreeColumnIndex := -1;
DrawGridLines := EXGRIDLib_TLB.exRowLines;
with (IUnknown(Columns.Add('Default')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
end;
with Items do
begin
CellHAlignment[OleVariant(AddItem('all-left')),OleVariant(0)] := EXGRIDLib_TLB.LeftAlignment;
CellHAlignment[OleVariant(AddItem('all-center')),OleVariant(0)] := EXGRIDLib_TLB.CenterAlignment;
CellHAlignment[OleVariant(AddItem('all-right')),OleVariant(0)] := EXGRIDLib_TLB.RightAlignment;
h := AddItem('left<c>center<r>right');
CellValueFormat[OleVariant(h),OleVariant(0)] := EXGRIDLib_TLB.exHTML;
end;
EndUpdate();
end
|
970
|
I have a column with Def(exCellSingleLine) property on False, word-wrapping, and I am wondering if possible to update the column's content while user is resizing it
with Grid1 do
begin
BeginUpdate();
with Columns do
begin
with (IUnknown(Add('MultipleLine')) as EXGRIDLib_TLB.Column) do
begin
Width := 32;
Def[EXGRIDLib_TLB.exCellSingleLine] := OleVariant(False);
Def[EXGRIDLib_TLB.exColumnResizeContiguously] := OleVariant(True);
end;
with (IUnknown(Add('SingleLine')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellSingleLine] := OleVariant(False);
end;
end;
with Items do
begin
CellValue[OleVariant(AddItem('This is a bit of long text that should break the line')),OleVariant(1)] := 'This is a bit of long text that should break the line';
end;
EndUpdate();
end
|
969
|
How can I get the absolute position of an item
// MouseMove event - Occurs when the user moves the mouse.
procedure TForm1.Grid1MouseMove(ASender: TObject; Button : Smallint;Shift : Smallint;X : Integer;Y : Integer);
begin
with Grid1 do
begin
with Items do
begin
OutputDebugString( CellCaption[OleVariant(Grid1.ItemFromPoint[-1,-1,c,hit]),'Position'] );
end;
end
end;
with Grid1 do
begin
BeginUpdate();
BackColorAlternate := RGB(240,240,240);
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
(IUnknown(Columns.Add('Def')) as EXGRIDLib_TLB.Column).DisplayFilterButton := True;
with Items do
begin
h := AddItem('Root');
InsertItem(InsertItem(h,Null,'Child 1'),Null,'Sub-Child 1');
InsertItem(InsertItem(h,Null,'Child 2'),Null,'Sub-Child 2');
end;
PutItems(GetItems(OleVariant(-1)),Null);
PutItems(GetItems(OleVariant(-1)),Null);
PutItems(GetItems(OleVariant(-1)),Null);
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '1 apos ``';
Visible := False;
end;
EndUpdate();
end
|
968
|
I am using ExComboBox as an user editor, how can I display a different column

// UserEditorClose event - Fired the user editor is about to be opened.
procedure TForm1.Grid1UserEditorClose(ASender: TObject; Object : IDispatch;Item : HITEM;ColIndex : Integer);
begin
// Items.CellValue(Item,ColIndex) = Object.Value
end;
// UserEditorOleEvent event - Occurs when an user editor fires an event.
procedure TForm1.Grid1UserEditorOleEvent(ASender: TObject; Object : IDispatch;Ev : IOleEvent;var CloseEditor : WordBool;Item : HITEM;ColIndex : Integer);
begin
with Grid1 do
begin
OutputDebugString( Ev );
end
end;
// UserEditorOpen event - Occurs when an user editor is about to be opened.
procedure TForm1.Grid1UserEditorOpen(ASender: TObject; Object : IDispatch;Item : HITEM;ColIndex : Integer);
begin
// Object.Value = Me.Items.CellValue(Item,ColIndex)
end;
with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('Exontrol.ComboBox')) as EXGRIDLib_TLB.Column).Editor do
begin
EditType := EXGRIDLib_TLB.UserEditorType;
UserEditor('Exontrol.ComboBox','');
with (IUnknown(UserEditorObject) as EXCOMBOBOXLib_TLB.ComboBox) do
begin
BeginUpdate();
Style := 2;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
Alignment := 0;
IntegralHeight := True;
MinHeightList := 128;
MinWidthList := 648;
HeaderHeight := 36;
AllowSizeGrip := True;
SingleEdit := True;
LabelColumnIndex := 7;
SearchColumnIndex := 0;
with Columns.Item[OleVariant(0)] do
begin
HeaderBold := True;
HTMLCaption := 'OrderID<br><fgcolor=808080>(search)';
end;
with Columns.Item[OleVariant(7)] do
begin
HeaderBold := True;
HTMLCaption := 'ShipName<br><fgcolor=808080>(display)';
Width := 128;
end;
UseTabKey := False;
EndUpdate();
end;
end;
DrawGridLines := EXGRIDLib_TLB.exRowLines;
DefaultItemHeight := 21;
with Items do
begin
CellEditorVisible[OleVariant(AddItem(OleVariant(10248))),OleVariant(0)] := EXGRIDLib_TLB.exEditorVisible;
CellEditorVisible[OleVariant(AddItem(OleVariant(10249))),OleVariant(0)] := EXGRIDLib_TLB.exEditorVisible;
CellEditorVisible[OleVariant(AddItem(OleVariant(10250))),OleVariant(0)] := EXGRIDLib_TLB.exEditorVisible;
end;
EndUpdate();
end
|
967
|
How do I sort the index column as numeric (Method 3)

// AddItem event - Occurs after a new Item has been inserted to Items collection.
procedure TForm1.Grid1AddItem(ASender: TObject; Item : HITEM);
begin
with Grid1 do
begin
with Items do
begin
CellData[OleVariant(Item),OleVariant(1)] := OleVariant(CellCaption[OleVariant(Item),OleVariant(1)]);
end;
end
end;
with Grid1 do
begin
BeginUpdate();
DrawGridLines := EXGRIDLib_TLB.exAllLines;
ColumnAutoResize := True;
ShowFocusRect := False;
with (IUnknown(Columns.Add('Next')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellPaddingLeft] := OleVariant(4);
Def[EXGRIDLib_TLB.exHeaderPaddingLeft] := OleVariant(4);
end;
with (IUnknown(Columns.Add('Index')) as EXGRIDLib_TLB.Column) do
begin
AllowSizing := False;
Width := 48;
FormatColumn := '(((0 := (1 index ``)) mod 3) case ( default: ``; 0 : `<r><fgcolor=B0B0B0>`; 1: ``; 2 : `<c><fgcolor=808080>` )) + str(=:0)';
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
SortType := EXGRIDLib_TLB.SortUserData;
Position := 0;
end;
with Items do
begin
AddItem('Item 1');
AddItem('Item 2');
AddItem('Item 3');
AddItem('Item 4');
AddItem('Item 5');
AddItem('Item 6');
AddItem('Item 7');
AddItem('Item 8');
AddItem('Item 9');
AddItem('Item 10');
end;
EndUpdate();
end
|
966
|
How do I sort the index column as numeric (Method 2)

// AddItem event - Occurs after a new Item has been inserted to Items collection.
procedure TForm1.Grid1AddItem(ASender: TObject; Item : HITEM);
begin
with Grid1 do
begin
with Items do
begin
CellSortData[OleVariant(Item),OleVariant(1)] := OleVariant(CellCaption[OleVariant(Item),OleVariant(1)]);
end;
end
end;
with Grid1 do
begin
BeginUpdate();
DrawGridLines := EXGRIDLib_TLB.exAllLines;
ColumnAutoResize := True;
ShowFocusRect := False;
with (IUnknown(Columns.Add('Next')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellPaddingLeft] := OleVariant(4);
Def[EXGRIDLib_TLB.exHeaderPaddingLeft] := OleVariant(4);
end;
with (IUnknown(Columns.Add('Index')) as EXGRIDLib_TLB.Column) do
begin
AllowSizing := False;
Width := 48;
FormatColumn := '(((0 := (1 index ``)) mod 3) case ( default: ``; 0 : `<r><fgcolor=B0B0B0>`; 1: ``; 2 : `<c><fgcolor=808080>` )) + str(=:0)';
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
SortType := EXGRIDLib_TLB.SortCellData;
Position := 0;
end;
with Items do
begin
AddItem('Item 1');
AddItem('Item 2');
AddItem('Item 3');
AddItem('Item 4');
AddItem('Item 5');
AddItem('Item 6');
AddItem('Item 7');
AddItem('Item 8');
AddItem('Item 9');
AddItem('Item 10');
end;
EndUpdate();
end
|
965
|
How do I sort the index column as numeric (Method 1)

with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('Sort Index As String (Default)')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '1 index ``';
end;
with (IUnknown(Columns.Add('Sort Index As Numeric')) as EXGRIDLib_TLB.Column) do
begin
ComputedField := '%C0';
SortType := EXGRIDLib_TLB.SortNumeric;
end;
with Items do
begin
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
end;
EndUpdate();
end
|
964
|
How can I put icons/images into buttons

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := True;
Images('gBJJgBAIDAAGAAEAAQhYAf8Pf4hh0QihCJo2AEZjQAjEZFEaIEaEEaAIAkcbk0olUrlktl0vmExmUzmk1m03nE5nU7nk9n0/oFBoVDolFo1HpFJpVLplNp1PqFRqVTql' +
'Vq1XrFZrVbrldr1fsFhsVjslls1ntFptVrtltt1vuFxuVzul1u13vF5vV7vl9v1/wGBwWDwmFw2HxGJxWLxmNx0xiFdyOTh8Tf9ZymXx+QytcyNgz8r0OblWjyWds+m0' +
'ka1Vf1ta1+r1mos2xrG2xeZ0+a0W0qOx3GO4NV3WeyvD2XJ5XL5nN51aiw+lfSj0gkUkAEllHanHI5j/cHg8EZf7w8vl8j4f/qfEZeB09/vjLAB30+kZQAP/P5/H6/yN' +
'AOAEAwCjMBwFAEDwJBMDwLBYAP2/8Hv8/gAGAD8LQs9w/nhDY/oygIA=');
with (IUnknown(Columns.Add('C+B')) as EXGRIDLib_TLB.Column) do
begin
AllowSizing := False;
Width := 48;
FormatColumn := '` <img>` + ( 1 + (1 index ``) mod 3 ) + `</img> `';
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
Def[EXGRIDLib_TLB.exCellHasButton] := OleVariant(True);
Def[EXGRIDLib_TLB.exCellButtonAutoWidth] := OleVariant(True);
end;
Columns.Add('');
DrawGridLines := EXGRIDLib_TLB.exVLines;
DefaultItemHeight := 20;
with Items do
begin
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
end;
EndUpdate();
end
|
963
|
Is it possible to have a CheckBox and Button TOGETHER on all cells in a column

// ButtonClick event - Occurs when user clicks on the cell's button.
procedure TForm1.Grid1ButtonClick(ASender: TObject; Item : HITEM;ColIndex : Integer;Key : OleVariant);
begin
with Grid1 do
begin
OutputDebugString( 'ButtonClick' );
OutputDebugString( Item );
OutputDebugString( Key );
end
end;
// CellStateChanged event - Fired after cell's state has been changed.
procedure TForm1.Grid1CellStateChanged(ASender: TObject; Item : HITEM;ColIndex : Integer);
begin
with Grid1 do
begin
OutputDebugString( 'CellStateChanged' );
OutputDebugString( Item );
end
end;
with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := True;
with (IUnknown(Columns.Add('')) as EXGRIDLib_TLB.Column) do
begin
AllowSizing := False;
Width := 32;
FormatColumn := '1 index ``';
end;
with (IUnknown(Columns.Add('Def')) as EXGRIDLib_TLB.Column) do
begin
AllowSizing := False;
Width := 48;
FormatColumn := '` `';
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
Def[EXGRIDLib_TLB.exCellHasButton] := OleVariant(True);
Def[EXGRIDLib_TLB.exCellButtonAutoWidth] := OleVariant(True);
end;
Columns.Add('');
with Items do
begin
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
AddItem('');
end;
EndUpdate();
end
|
962
|
I have columns that look up the same data. (e.g. different contact) so both could / should use the same editor. Is this possible, to use other column's editor

with Grid1 do
begin
BeginUpdate();
SelBackColor := BackColor;
SelForeColor := ForeColor;
with Columns do
begin
with (IUnknown(Add('Pos')) as EXGRIDLib_TLB.Column) do
begin
Width := 32;
AllowSizing := False;
FormatColumn := '1 index ``';
end;
var_Editor := Add('C1').Editor;
with var_Editor do
begin
EditType := EXGRIDLib_TLB.ColorListType;
ClearItems();
AddItem(255,'Red Color',Null);
AddItem(16711680,'Blue Color',Null);
AddItem(65280,'Green Color',Null);
end;
(IUnknown(Add('C2')) as EXGRIDLib_TLB.Column).Editor.EditType := Integer(EXGRIDLib_TLB.CloneType) Or Integer(EXGRIDLib_TLB.EditType);
(IUnknown(Add('C3')) as EXGRIDLib_TLB.Column).Editor.EditType := Integer(EXGRIDLib_TLB.CloneType) Or Integer(EXGRIDLib_TLB.EditType);
end;
with Items do
begin
h := AddItem('');
CellValue[OleVariant(h),OleVariant(1)] := OleVariant(16711680);
CellValue[OleVariant(h),OleVariant(2)] := OleVariant(65280);
CellValue[OleVariant(h),OleVariant(3)] := OleVariant(255);
h := AddItem('');
CellValue[OleVariant(h),OleVariant(1)] := OleVariant(255);
CellValue[OleVariant(h),OleVariant(2)] := OleVariant(16711680);
CellValue[OleVariant(h),OleVariant(3)] := OleVariant(65280);
end;
EndUpdate();
end
|
961
|
Is there an easy way to get an effect like in a Microsoft Access / SQL-Server Table view, where you can scroll-up till the last row containing data is displayed as top-row

with Grid1 do
begin
BeginUpdate();
HasLines := EXGRIDLib_TLB.exNoLine;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
ScrollBars := Integer(EXGRIDLib_TLB.exVScrollEmptySpace) Or Integer(EXGRIDLib_TLB.exBoth);
ScrollPos[True] := Items.ItemCount;
EndUpdate();
end
|
960
|
Does filtering work with umlauts / accents characters
with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('Names')) as EXGRIDLib_TLB.Column) do
begin
DisplayFilterButton := True;
FilterType := EXGRIDLib_TLB.exPattern;
end;
with Items do
begin
AddItem('Mantel');
AddItem('Mechanik');
AddItem('Motor');
AddItem('Murks');
AddItem('Märchen');
AddItem('Möhren');
AddItem('Mühle');
AddItem('Sérigraphie');
end;
Columns.Item[OleVariant(0)].Filter := '*ä*';
ApplyFilter();
EndUpdate();
end
|
959
|
How FullPath method works

with Grid1 do
begin
BeginUpdate();
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
Columns.Add('C1');
Columns.Add('C2');
with Items do
begin
h := AddItem('Root');
CellValue[OleVariant(h),OleVariant(1)] := 'A';
CellValue[OleVariant(InsertItem(h,Null,'Child 1')),OleVariant(1)] := 'B';
CellValue[OleVariant(InsertItem(h,Null,'Child 2')),OleVariant(1)] := 'C';
ExpandItem[h] := True;
end;
SearchColumnIndex := 1;
OutputDebugString( SearchColumnIndex );
OutputDebugString( Items.FullPath[.ItemByIndex[2]] );
SearchColumnIndex := 0;
OutputDebugString( SearchColumnIndex );
OutputDebugString( Items.FullPath[.ItemByIndex[2]] );
EndUpdate();
end
|
958
|
Can I set the search box / filterbarprompt to invisible, so I can use my own input and *string* via VBA
with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := True;
ContinueColumnScroll := False;
MarkSearchColumn := False;
SearchColumnIndex := 1;
FilterBarHeight := 0;
FilterBarPromptVisible := EXGRIDLib_TLB.exFilterBarPromptVisible;
with Columns do
begin
(IUnknown(Add('Name')) as EXGRIDLib_TLB.Column).Width := 96;
(IUnknown(Add('Title')) as EXGRIDLib_TLB.Column).Width := 96;
Add('City');
end;
with Items do
begin
h0 := AddItem('Nancy Davolio');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Representative';
CellValue[OleVariant(h0),OleVariant(2)] := 'Seattle';
h0 := AddItem('Andrew Fuller');
CellValue[OleVariant(h0),OleVariant(1)] := 'Vice President, Sales';
CellValue[OleVariant(h0),OleVariant(2)] := 'Tacoma';
SelectItem[h0] := True;
h0 := AddItem('Janet Leverling');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Representative';
CellValue[OleVariant(h0),OleVariant(2)] := 'Kirkland';
h0 := AddItem('Margaret Peacock');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Representative';
CellValue[OleVariant(h0),OleVariant(2)] := 'Redmond';
h0 := AddItem('Steven Buchanan');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Manager';
CellValue[OleVariant(h0),OleVariant(2)] := 'London';
h0 := AddItem('Michael Suyama');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Representative';
CellValue[OleVariant(h0),OleVariant(2)] := 'London';
h0 := AddItem('Robert King');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Representative';
CellValue[OleVariant(h0),OleVariant(2)] := 'London';
h0 := AddItem('Laura Callahan');
CellValue[OleVariant(h0),OleVariant(1)] := 'Inside Sales Coordinator';
CellValue[OleVariant(h0),OleVariant(2)] := 'Seattle';
h0 := AddItem('Anne Dodsworth');
CellValue[OleVariant(h0),OleVariant(1)] := 'Sales Representative';
CellValue[OleVariant(h0),OleVariant(2)] := 'London';
end;
FilterBarPromptPattern := 'London';
EndUpdate();
end
|
957
|
How to load a hierarchy using the control's DataSource property (Parent-ID-Relation)

// AddItem event - Occurs after a new Item has been inserted to Items collection.
procedure TForm1.Grid1AddItem(ASender: TObject; Item : HITEM);
begin
with Grid1 do
begin
with Items do
begin
SetParent(Item,FindItem[CellValue[OleVariant(Item),'ReportsTo'],'EmployeeID',Null]);
end;
end
end;
with Grid1 do
begin
BeginUpdate();
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
ColumnAutoResize := False;
ContinueColumnScroll := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('SELECT * FROM Employees ORDER BY ReportsTo','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
Items.ExpandItem[0] := True;
EndUpdate();
end
|
956
|
Is it possible to select the entire row/line, when user clicks the first column, and select individually the rest of cells, while user clicks any other column

// MouseDown event - Occurs when the user presses a mouse button.
procedure TForm1.Grid1MouseDown(ASender: TObject; Button : Smallint;Shift : Smallint;X : Integer;Y : Integer);
begin
with Grid1 do
begin
i := ItemFromPoint[-1,-1,c,hit];
FullRowSelect := Columns.Item[OleVariant(c)].Data;
end
end;
with Grid1 do
begin
BeginUpdate();
HeaderHeight := 22;
HeaderAppearance := EXGRIDLib_TLB.Flat;
BackColorLock := RGB(240,240,240);
BackColorHeader := BackColorLock;
HasLines := EXGRIDLib_TLB.exNoLine;
ColumnAutoResize := False;
SortBarVisible := False;
AllowGroupBy := True;
ReadOnly := EXGRIDLib_TLB.exReadOnly;
ShowFocusRect := False;
CountLockedColumns := 1;
AutoDrag := EXGRIDLib_TLB.exAutoDragScroll;
SingleSort := False;
ColumnsAllowSizing := True;
DrawGridLines := EXGRIDLib_TLB.exAllLines;
GridLineStyle := EXGRIDLib_TLB.exGridLinesSolid;
GridLineColor := RGB(220,220,220);
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
Columns.Item[OleVariant(0)].Data := OleVariant(-1);
Layout := 'singlesort="C5:1";multiplesort=" C1:2"';
EndUpdate();
end
|
955
|
The user are not able to size the columns at runtime when using HeaderAppearance property on zero
with Grid1 do
begin
VisualAppearance.Add(1,'gBFLBCJwBAEHhEJAAEhABJEIQAAYAQGKIYBkAKBQAGaAoDDcMQ5QwAAyDGKEEwsACEIrjKCRShyCYZRhGcTSBCIZBqEqSZLiEZRQiiCYsS5GQBSFDcOwHGyQZonKK3Lh' +
'GCYBgIA=');
HeaderAppearance := EXGRIDLib_TLB.AppearanceEnum($1000000);
Columns.Add(1);
Columns.Add(2);
Columns.Add(3);
end
|
954
|
Is it possible to embed the exGauge into the exGrid control

// ItemOleEvent event - Fired when an ActiveX control hosted by an item has fired an event.
procedure TForm1.Grid1ItemOleEvent(ASender: TObject; Item : HITEM;Ev : IOleEvent);
begin
with Grid1 do
begin
with (IUnknown(Items.ItemObject[Grid1.Items.ItemByIndex[2]]) as EXGAUGELib_TLB.Gauge) do
begin
v := FormatABC('date(`now`)',Null,Null,Null);
Layers.Item['sec'].Value := OleVariant(v);
Layers.Item['min'].Value := OleVariant(v);
Layers.Item['hour'].Value := OleVariant(v);
end;
end
end;
// MouseMove event - Occurs when the user moves the mouse.
procedure TForm1.Grid1MouseMove(ASender: TObject; Button : Smallint;Shift : Smallint;X : Integer;Y : Integer);
begin
with Grid1 do
begin
with (IUnknown(Items.ItemObject[Grid1.Items.ItemByIndex[2]]) as EXGAUGELib_TLB.Gauge) do
begin
TimerInterval := 1000;
end;
end
end;
with Grid1 do
begin
BeginUpdate();
ScrollBySingleLine := True;
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
HasLines := EXGRIDLib_TLB.exThinLine;
ScrollBySingleLine := True;
Columns.Add('Default');
with Items do
begin
h := AddItem('Normal Item');
h := AddItem('Gauge-Clock Inside');
ExpandItem[h] := True;
h := InsertControlItem(h,'Exontrol.Gauge',Null);
ItemHeight[h] := 256;
with (IUnknown(ItemObject[h]) as EXGAUGELib_TLB.Gauge) do
begin
PicturesPath := 'C:\Program Files\Exontrol\ExGauge\Sample\Design\Circular\Clock';
DefaultLayer[185] := OleVariant(2);
Layers.Count := 4;
with Layers.Item[OleVariant(0)] do
begin
Background.Picture.Name := 'vista_clock.png';
end;
with Layers.Item[OleVariant(1)] do
begin
Position := 3;
Key := 'sec';
OnDrag := 2;
Selectable := False;
Background.Picture.Name := 'second-hand.png';
ValueToRotateAngle := '((2:=(((1:=( ( (0:=(value < 0 ? floor(value) + 1 - value : value - floor(value))) < 0.5 ? =:0 : (0:= (=:0 - 0.5)) ) * 24 )) - f' +
'loor(=:1)) * 60 )) - floor(=:2) ) * 360';
RotateAngleToValue := 'value / 360 / 24 / 60';
end;
with Layers.Item[OleVariant(2)] do
begin
Position := 2;
Key := 'min';
OnDrag := 2;
Selectable := False;
Background.Picture.Name := 'Minute.png';
ValueToRotateAngle := '((1:=( ( (0:=(value < 0 ? floor(value) + 1 - value : value - floor(value))) < 0.5 ? =:0 : (0:= (=:0 - 0.5)) ) * 24 )) - floor(=' +
':1)) * 360';
RotateAngleToValue := 'value / 360 / 24 / 60';
end;
with Layers.Item[OleVariant(3)] do
begin
Position := 1;
Key := 'hour';
OnDrag := 2;
Background.Picture.Name := 'Hour.png';
ValueToRotateAngle := '2 * 360 * ( (0:=(value < 0 ? floor(value) + 1 - value : value - floor(value))) < 0.5 ? =:0 : (0:= (=:0 - 0.5)) )';
RotateAngleToValue := 'value / 360 * 0.5';
end;
v := FormatABC('date(`now`)',Null,Null,Null);
Layers.Item['sec'].Value := OleVariant(v);
Layers.Item['min'].Value := OleVariant(v);
Layers.Item['hour'].Value := OleVariant(v);
end;
h := AddItem('Normal Item');
end;
EndUpdate();
end
|
953
|
What's the difference between merge cells and divider item

// AddItem event - Occurs after a new Item has been inserted to Items collection.
procedure TForm1.Grid1AddItem(ASender: TObject; Item : HITEM);
begin
with Grid1 do
begin
with Items do
begin
CellBackColor[OleVariant(Item),OleVariant(0)] := $f0f0f0;
ItemHasChildren[Item] := True;
end;
end
end;
with Grid1 do
begin
BeginUpdate();
TreeColumnIndex := 0;
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
DrawGridLines := EXGRIDLib_TLB.exAllLines;
(IUnknown(Columns.Add('C1')) as EXGRIDLib_TLB.Column).FormatColumn := '1 index `A-Z`';
(IUnknown(Columns.Add('C2')) as EXGRIDLib_TLB.Column).FormatColumn := '1 index ``';
(IUnknown(Columns.Add('C3')) as EXGRIDLib_TLB.Column).FormatColumn := '1 index ``';
with Items do
begin
AddItem(Null);
AddItem(Null);
h := AddItem(Null);
CellMerge[OleVariant(h),OleVariant(0)] := OleVariant(1);
FormatCell[OleVariant(h),OleVariant(0)] := '`merge cells`';
CellHAlignment[OleVariant(h),OleVariant(0)] := EXGRIDLib_TLB.CenterAlignment;
h := AddItem(Null);
ItemDivider[h] := 0;
CellHAlignment[OleVariant(h),OleVariant(0)] := EXGRIDLib_TLB.CenterAlignment;
FormatCell[OleVariant(h),OleVariant(0)] := '`item divider`';
AddItem(Null);
AddItem(Null);
end;
EndUpdate();
end
|
952
|
is it possible to resize a column with the mouse without changing the width of the next column

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
(IUnknown(Columns.Add('Column 1')) as EXGRIDLib_TLB.Column).Width := 256;
(IUnknown(Columns.Add('Column 2')) as EXGRIDLib_TLB.Column).Width := 512;
DrawGridLines := EXGRIDLib_TLB.exAllLines;
EndUpdate();
end
|
951
|
How do I ensure that the newly item fits the control's client area

// ButtonClick event - Occurs when user clicks on the cell's button.
procedure TForm1.Grid1ButtonClick(ASender: TObject; Item : HITEM;ColIndex : Integer;Key : OleVariant);
begin
with Grid1 do
begin
with Items do
begin
h := AddItem('');
SelectItem[h] := True;
EnsureVisibleItem(h);
end;
FocusColumnIndex := 0;
end
end;
with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('')) as EXGRIDLib_TLB.Column) do
begin
AllowSizing := False;
AllowDragging := False;
AllowSort := False;
Width := 24;
Def[EXGRIDLib_TLB.exCellHasButton] := OleVariant(True);
end;
(IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column).FormatColumn := '1 apos `A-Z`';
CountLockedColumns := 1;
with Items do
begin
AddItem('');
AddItem('');
AddItem('');
end;
EndUpdate();
end
|
950
|
How do I find the predefined string for giving value, or giving identifier for specified predefined caption of editor

// Change event - Occurs when the user changes the cell's content.
procedure TForm1.Grid1Change(ASender: TObject; Item : HITEM;ColIndex : Integer;var NewValue : OleVariant);
begin
with Grid1 do
begin
OutputDebugString( 'FindItem(numeric) is ' );
OutputDebugString( NewValue );
OutputDebugString( Columns.Item[OleVariant(0)].Editor.FindItem[OleVariant(NewValue)] );
end
end;
with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('DropDownList')) as EXGRIDLib_TLB.Column) do
begin
with Editor do
begin
EditType := EXGRIDLib_TLB.DropDownListType;
AddItem(1,'Ken Robinson',Null);
AddItem(2,'Dave Nichols',Null);
AddItem(3,'Zane Thomas',Null);
AddItem(4,'James Shields',Null);
end;
end;
with (IUnknown(Columns.Add('CellValue')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '%0';
Def[EXGRIDLib_TLB.exCellBackColor] := OleVariant(15790320);
Def[EXGRIDLib_TLB.exHeaderBackColor] := Def[EXGRIDLib_TLB.exCellBackColor];
end;
with (IUnknown(Columns.Add('CellCaption')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '%C0';
Def[EXGRIDLib_TLB.exCellBackColor] := OleVariant(15790320);
Def[EXGRIDLib_TLB.exHeaderBackColor] := Def[EXGRIDLib_TLB.exCellBackColor];
end;
with Items do
begin
AddItem(OleVariant(1));
AddItem(Grid1.Columns.Item[OleVariant(0)].Editor.FindItem['Zane Thomas']);
AddItem(OleVariant(2));
end;
EndUpdate();
end
|
949
|
How can I align captions of items with checkbox, with items with no checkbox

with Grid1 do
begin
BeginUpdate();
Columns.Add('Default');
with Items do
begin
CellImages[OleVariant(AddItem(OleVariant(0))),OleVariant(0)] := '1';
CellHasCheckBox[OleVariant(AddItem(OleVariant(1))),OleVariant(0)] := True;
CellImages[OleVariant(AddItem(OleVariant(2))),OleVariant(0)] := '1';
end;
EndUpdate();
end
|
948
|
How can I prevent sorting a column

with Grid1 do
begin
BeginUpdate();
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
with (IUnknown(Columns.Add('Default')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
PartialCheck := True;
AllowSort := False;
end;
with Items do
begin
h := AddItem('Root');
InsertItem(h,Null,'Child 1');
InsertItem(h,Null,'Child 2');
ExpandItem[h] := True;
end;
EndUpdate();
end
|
947
|
Is there a possibility to group without moving and showing the column to the SortBar

with Grid1 do
begin
BeginUpdate();
HasLines := EXGRIDLib_TLB.exNoLine;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
SingleSort := False;
SortBarVisible := False;
AllowGroupBy := True;
Layout := 'singlesort="C5:1";multiplesort=" C1:2"';
EndUpdate();
end
|
946
|
How can I show each group header ( not-subroup ), with a different background color, while alternate background colors for inside items

// LayoutChanged event - Occurs when column's position or column's size is changed.
procedure TForm1.Grid1LayoutChanged(ASender: TObject; );
begin
with Grid1 do
begin
Refresh();
end
end;
with Grid1 do
begin
BeginUpdate();
HasLines := EXGRIDLib_TLB.exNoLine;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
SingleSort := False;
SortBarVisible := True;
AllowGroupBy := True;
Columns.Item[OleVariant(1)].SortOrder := True;
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '(0:= (1 rpos '''')) right ( ( 1:= ( =:0 rfind `.` ) ) != -1 ? =:1 : len(=:0))';
Visible := False;
end;
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '(1 rpos '''') contains ''.''';
Visible := False;
end;
ConditionalFormats.Add('(%C13 mod 2) != 0',Null).BackColor := $f0f0f0;
ConditionalFormats.Add('%C14 = 0',Null).BackColor := $bebebe;
EndUpdate();
end
|
945
|
What is the difference between %0 and %C0, when using in expressions ( format, conditional format, computed fields, and so on )

with Grid1 do
begin
BeginUpdate();
HeaderAppearance := EXGRIDLib_TLB.Etched;
HeaderHeight := 24;
ScrollBySingleLine := True;
DrawGridLines := EXGRIDLib_TLB.exRowLines;
(IUnknown(Columns.Add('Value')) as EXGRIDLib_TLB.Column).Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
with (IUnknown(Columns.Add('FormatColumn = `%0` ~ CellValue')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '%0';
Def[EXGRIDLib_TLB.exCellSingleLine] := OleVariant(False);
end;
with (IUnknown(Columns.Add('FormatColumn = `%C0`~ CellCaption')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '%C0';
Def[EXGRIDLib_TLB.exCellSingleLine] := OleVariant(False);
end;
with Items do
begin
AddItem(OleVariant(1.1234));
CellValueFormat[OleVariant(AddItem('<sha ;;0>This <fgcolor=FF0000>is a <s><b>HTM</fgcolor>L</b> text</s>.')),OleVariant(0)] := EXGRIDLib_TLB.exHTML;
with CellEditor[OleVariant(AddItem(OleVariant(3))),Null] do
begin
EditType := EXGRIDLib_TLB.CheckListType;
AddItem(1,'Border',Null);
AddItem(2,'Thick',Null);
AddItem(4,'Shadow',Null);
end;
FormatCell[OleVariant(AddItem(OleVariant(10000))),OleVariant(0)] := '`<b>` + currency(value)';
end;
EndUpdate();
end
|
944
|
How can I alternate colors for each group header ( not-subroup ), with a different background color, while items of the same group showing with a different color

// LayoutChanged event - Occurs when column's position or column's size is changed.
procedure TForm1.Grid1LayoutChanged(ASender: TObject; );
begin
with Grid1 do
begin
Refresh();
end
end;
with Grid1 do
begin
BeginUpdate();
HasLines := EXGRIDLib_TLB.exNoLine;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
SingleSort := False;
SortBarVisible := True;
AllowGroupBy := True;
Columns.Item[OleVariant(1)].SortOrder := True;
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '(0:= (1 rpos '''')) left ( ( 1:= ( =:0 lfind `.` ) ) != -1 ? =:1 : len(=:0))';
Visible := False;
end;
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '(1 rpos '''') contains ''.''';
Visible := False;
end;
ConditionalFormats.Add('(%C13 mod 2) != 0',Null).BackColor := $f0f0f0;
ConditionalFormats.Add('%C14 = 0',Null).BackColor := $bebebe;
EndUpdate();
end
|
943
|
How can I highlight each group header, with a different background color (method 2)

// AddGroupItem event - Occurs after a new Group Item has been inserted to Items collection.
procedure TForm1.Grid1AddGroupItem(ASender: TObject; Item : HITEM);
begin
with Grid1 do
begin
Items.ItemBackColor[Item] := $bebebe;
end
end;
with Grid1 do
begin
BeginUpdate();
HasLines := EXGRIDLib_TLB.exNoLine;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
SingleSort := False;
SortBarVisible := True;
AllowGroupBy := True;
Columns.Item[OleVariant(1)].SortOrder := True;
EndUpdate();
end
|
942
|
How can I highlight each group header ( not-subroup ), with a different background color (method 1)

// LayoutChanged event - Occurs when column's position or column's size is changed.
procedure TForm1.Grid1LayoutChanged(ASender: TObject; );
begin
with Grid1 do
begin
Refresh();
end
end;
with Grid1 do
begin
BeginUpdate();
HasLines := EXGRIDLib_TLB.exNoLine;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
SingleSort := False;
SortBarVisible := True;
AllowGroupBy := True;
Columns.Item[OleVariant(1)].SortOrder := True;
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '(0:= (1 rpos '''')) left ( ( 1:= ( =:0 lfind `.` ) ) != -1 ? =:1 : len(=:0))';
Visible := False;
end;
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '(1 rpos '''') contains ''.''';
Visible := False;
end;
ConditionalFormats.Add('%C14 = 0',Null).BackColor := $bebebe;
EndUpdate();
end
|
941
|
The BackColorAlternate displays each second row with a different background color. Is it possible to apply a different background color, for each sub-tree, ConditionalFormats, Add

// LayoutChanged event - Occurs when column's position or column's size is changed.
procedure TForm1.Grid1LayoutChanged(ASender: TObject; );
begin
with Grid1 do
begin
Refresh();
end
end;
// Sort event - Fired when the control sorts a column.
procedure TForm1.Grid1Sort(ASender: TObject; );
begin
with Grid1 do
begin
Refresh();
end
end;
with Grid1 do
begin
BeginUpdate();
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
with (IUnknown(Columns.Add('P1')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
PartialCheck := True;
end;
with (IUnknown(Columns.Add('P2')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
PartialCheck := True;
end;
with Items do
begin
h := AddItem('Root 1');
InsertItem(h,Null,'Child 1');
InsertItem(h,Null,'Child 2');
ExpandItem[h] := True;
h := AddItem('Root 2');
InsertItem(h,Null,'Child 1');
InsertItem(h,Null,'Child 2');
ExpandItem[h] := True;
h := AddItem('Root 2');
InsertItem(h,Null,'Child 1');
InsertItem(h,Null,'Child 2');
ExpandItem[h] := True;
end;
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '(0:= (1 rpos '''')) left ( ( 1:= ( =:0 lfind `.` ) ) != -1 ? =:1 : len(=:0))';
Visible := False;
end;
ConditionalFormats.Add('(%C2 mod 2) != 0',Null).BackColor := $f0f0f0;
EndUpdate();
end
|
940
|
The BackColorAlternate displays each second row with a different background color. Is it possible to apply a different background color, for 2nd, 3rd, 4th, row, and so on

// LayoutChanged event - Occurs when column's position or column's size is changed.
procedure TForm1.Grid1LayoutChanged(ASender: TObject; );
begin
with Grid1 do
begin
Refresh();
end
end;
// Sort event - Fired when the control sorts a column.
procedure TForm1.Grid1Sort(ASender: TObject; );
begin
with Grid1 do
begin
Refresh();
end
end;
with Grid1 do
begin
BeginUpdate();
HasLines := EXGRIDLib_TLB.exNoLine;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '1 apos ''''';
Visible := False;
end;
ConditionalFormats.Add('(%C13 mod 5) = 1',Null).BackColor := $808080;
ConditionalFormats.Add('(%C13 mod 5) = 2',Null).BackColor := $a4a4a4;
ConditionalFormats.Add('(%C13 mod 5) = 3',Null).BackColor := $bebebe;
ConditionalFormats.Add('(%C13 mod 5) = 4',Null).BackColor := $f0f0f0;
EndUpdate();
end
|
939
|
The BackColorAlternate displays each second row with a different background color. The question I have it is possible to apply a different background color for 3rd, 4th, row, and so on

// LayoutChanged event - Occurs when column's position or column's size is changed.
procedure TForm1.Grid1LayoutChanged(ASender: TObject; );
begin
with Grid1 do
begin
Refresh();
end
end;
// Sort event - Fired when the control sorts a column.
procedure TForm1.Grid1Sort(ASender: TObject; );
begin
with Grid1 do
begin
Refresh();
end
end;
with Grid1 do
begin
BeginUpdate();
HasLines := EXGRIDLib_TLB.exNoLine;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '1 apos ''''';
Visible := False;
end;
ConditionalFormats.Add('(%C13 mod 4) = 0',Null).BackColor := $f0f0f0;
EndUpdate();
end
|
938
|
The BackColorAlternate looks fine for flat tables, but how about using it when displaying a hierarchy/tree, like grouping rows. The sample alternate colors for each group found

// LayoutChanged event - Occurs when column's position or column's size is changed.
procedure TForm1.Grid1LayoutChanged(ASender: TObject; );
begin
with Grid1 do
begin
Refresh();
end
end;
with Grid1 do
begin
BeginUpdate();
HasLines := EXGRIDLib_TLB.exNoLine;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
SingleSort := False;
SortBarVisible := True;
AllowGroupBy := True;
Columns.Item[OleVariant(1)].SortOrder := True;
with (IUnknown(Columns.Add('Position')) as EXGRIDLib_TLB.Column) do
begin
FormatColumn := '(0:= (1 rpos '''')) left ( ( 1:= ( =:0 lfind `.` ) ) != -1 ? =:1 : len(=:0))';
Visible := False;
end;
ConditionalFormats.Add('(%C13 mod 2) != 0',Null).BackColor := $f0f0f0;
EndUpdate();
end
|
937
|
I need to display sub-totals in the grouping items. Is there any solution on this

// AddGroupItem event - Occurs after a new Group Item has been inserted to Items collection.
procedure TForm1.Grid1AddGroupItem(ASender: TObject; Item : HITEM);
begin
with Grid1 do
begin
with Items do
begin
ItemDivider[Item] := -1;
EnableItem[Item] := False;
CellValueFormat[OleVariant(Item),OleVariant(Grid1.TreeColumnIndex)] := EXGRIDLib_TLB.exHTML;
FormatCell[OleVariant(Item),OleVariant(Grid1.TreeColumnIndex)] := '%1';
CellValueFormat[OleVariant(Item),'Freight'] := Integer(EXGRIDLib_TLB.exTotalField) Or Integer(EXGRIDLib_TLB.exHTML);
CellValue[OleVariant(Item),'Freight'] := 'sum(current,dir,%6)';
FormatCell[OleVariant(Item),'Freight'] := '`<b>` + currency(value)';
end;
end
end;
with Grid1 do
begin
BeginUpdate();
SelBackMode := EXGRIDLib_TLB.exTransparent;
BackColorSortBar := RGB(240,240,240);
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
SortBarVisible := True;
SortBarCaption := 'Drag a <b>column</b> header here to group by that column.';
AllowGroupBy := True;
Columns.Item[OleVariant(1)].SortOrder := EXGRIDLib_TLB.SortAscending;
LinesAtRoot := EXGRIDLib_TLB.exGroupLinesOutside;
Columns.Item['ShipVia'].DisplayFilterButton := True;
EndUpdate();
end
|
936
|
I use a subtotal in exTop-Item, after grouping the item shows 0. What is the solution

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
SingleSort := False;
AllowGroupBy := True;
SortBarVisible := True;
BackColorSortBar := BackColor;
Columns.Item[OleVariant(5)].SortOrder := EXGRIDLib_TLB.SortAscending;
Columns.Item[OleVariant(6)].FormatColumn := 'currency(value)';
with Items do
begin
LockedItemCount[EXGRIDLib_TLB.exTop] := 1;
h := LockedItem[EXGRIDLib_TLB.exTop,0];
ItemBackColor[h] := $f0f0f0;
CellBackColor[OleVariant(h),OleVariant(6)] := $bebebe;
CellValue[OleVariant(h),OleVariant(6)] := 'sum(all,rec,%6)';
CellValueFormat[OleVariant(h),OleVariant(6)] := EXGRIDLib_TLB.exTotalField;
end;
Refresh();
EndUpdate();
end
|
935
|
I would like to avoid manual typing in the date-cell because user often type wrong things (no decimal points and so on) and so the todays-date is generated for the cell. What can be done

// KeyPress event - Occurs when the user presses and releases an ANSI key.
procedure TForm1.Grid1KeyPress(ASender: TObject; var KeyAscii : Smallint);
begin
with Grid1 do
begin
OutputDebugString( 'if .Editying != 0 then' );
OutputDebugString( Editing );
KeyAscii := 0;
end
end;
with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
with Columns do
begin
Add('Tasks');
with (IUnknown(Add('Date')) as EXGRIDLib_TLB.Column) do
begin
Editor.EditType := EXGRIDLib_TLB.DateType;
Width := 128;
end;
end;
with Items do
begin
CellValue[OleVariant(AddItem('Item 1')),OleVariant(1)] := '9/21/2006';
CellValue[OleVariant(AddItem('Item 2')),OleVariant(1)] := '12/22/2015';
CellValue[OleVariant(AddItem('Item 3')),OleVariant(1)] := '1/10/2015';
end;
EndUpdate();
end
|
934
|
The control does not ensure the item to fit the control's client area once the user clicks the cell's button or check box. What can be done
// MouseDown event - Occurs when the user presses a mouse button.
procedure TForm1.Grid1MouseDown(ASender: TObject; Button : Smallint;Shift : Smallint;X : Integer;Y : Integer);
begin
// Items.EnsureVisibleItem(ItemFromPoint(-1,-1,c,hit))
end;
with Grid1 do
begin
BeginUpdate();
TreeColumnIndex := -1;
SelForeColor := ForeColor;
with (IUnknown(Columns.Add('Buttons')) as EXGRIDLib_TLB.Column) do
begin
Alignment := EXGRIDLib_TLB.CenterAlignment;
Def[EXGRIDLib_TLB.exCellHasButton] := OleVariant(True);
end;
with Items do
begin
AddItem('Button A');
AddItem('Button B');
AddItem('Button C');
end;
EndUpdate();
end
|
933
|
How do you save the index number from a drop down to a database

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
with Columns.Item['ShipVia'] do
begin
Def[EXGRIDLib_TLB.exCellBackColor] := OleVariant(15790320);
Position := 1;
Width := 96;
with Editor do
begin
EditType := EXGRIDLib_TLB.DropDownListType;
AddItem(1,'Speedy Express',Null);
AddItem(2,'United Package',Null);
AddItem(3,'Federal Shipping',Null);
end;
end;
EndUpdate();
end
|
932
|
Is there a way to set the column width and have it stay when refreshing using the data source

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
Layout := 'gBjAAwAAuABmABpABsAB0ABlAByhoAPIAOEPAA9gYABoABQAgUEg0XN4AOcJicKkpujIAGMcj0gjcGk8QhkQgUOjUEjsfkMFAB2lEnhRihcYjUvnsykQAO8oMkTNEtGg' +
'AGUwn0uoEIhUMh0QiUOisXiE7rEyl8jAElokptYAllmpcCtMmjE3mU6jdzrUGoUKttGvFJs90oFPhVRh1Twg4wtaptco9fiMTsdIvcxw1Nkl2hUOlVwlsvnmayFAmtHn' +
'ETuWm0lAv+eAGCzFK10zp1QqVUAGOvkvuuSr0YsMUi2Y0tZ4FAztt0FvuNa23Kvt2m0YnMt5No6uxwOq0eP5cGxAAxQAxgAGwAqu/q1blHDsGW49lzPUq9qtko58r8Kr' +
'vc/LrPA7LWvw2ChpQ2j7Om7kBPK870hu+6ZQE4SJvmsT6u0x8BOa/iUP8jUANNATUrxAsKIFATvQU8DCL5B7dMWlr1u2gQZvgrsMMrDSyQ4vkcv02T+tEjUcyC1C7uw1' +
'kVABISgwSosXq1JLyRm9EaycqqDQuyjisu+0bvY5i3udEMjTIvkuQHFEmzHNkWymwcqtNNkIN2jUbMeGsdMm4j6R/AyZT7IcztC6M+r5Qs2yYvUx0ZOTZypBqBUZPEaM' +
'ax71y6+MeTBDdBoFTjjv2z80Oi9a+VJE9HSA01SUlBbw1Ww8sPSqtFNNCdOx3L9AuQx9eVLIlUJbCa+WHVrV0fYUEMBF06UqAFh0xLLCT7abHV7P8MuNQUnW3YlDuglr' +
'fNNcVlrzV6s3FWVKMfcVrPSq6rva0wcz8+Ue2/YK+XzQ0QUQlt83/JTr2ZdiZYBKNoTm2rH4ZedzSckqGDqAA2tEk7CSQmKEJKgWMY5CmQJlkaZYsAGMY0liFJYqKIDx' +
'hSpjCu0vUBQappOgSJZUhlBtTmyJIEqaBZVljRZe8yMZnoMl4SjQRI3qal3U7OjqPpOXNFmIAadCiHIkiDV6RjOla7puFKFnjK5/ta7Z6t6GIYkqEIQ1NmqWgIA=';
EndUpdate();
end
|
931
|
Is it possible to decode/view the control's Layout property

with Grid1 do
begin
BeginUpdate();
SingleSort := False;
Columns.Add('C0');
(IUnknown(Columns.Add('C1')) as EXGRIDLib_TLB.Column).SortOrder := EXGRIDLib_TLB.SortAscending;
Columns.Add('C2');
with (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('Exontrol.Print'))) as EXPRINTLib_TLB.Print) do
begin
OutputDebugString( Decode64TextW[Grid1.Layout] );
end;
EndUpdate();
end
|
930
|
How do I programmatically sort by multiple columns

with Grid1 do
begin
BeginUpdate();
SingleSort := False;
Columns.Add('C0');
Columns.Add('C1');
Columns.Add('C2');
Layout := 'multiplesort="C2:1 C1:2 C0:2"';
EndUpdate();
end
|
929
|
Do you have any Fit-To-Page options when printing the control (W x T, Fit-To )

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
ContinueColumnScroll := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
EndUpdate();
with (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('Exontrol.Print'))) as EXPRINTLib_TLB.Print) do
begin
Options := 'FitToPage =2 x 1';
PrintExt := (IUnknown(Grid1.DefaultInterface) as EXGRIDLib_TLB.Grid);
Preview();
end;
end
|
928
|
Do you have any Fit-To-Page options when printing the control ( x T, Fit-To Tall )

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
ContinueColumnScroll := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
EndUpdate();
with (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('Exontrol.Print'))) as EXPRINTLib_TLB.Print) do
begin
Options := 'FitToPage = x 2';
PrintExt := (IUnknown(Grid1.DefaultInterface) as EXGRIDLib_TLB.Grid);
Preview();
end;
end
|
927
|
Do you have any Fit-To-Page options when printing the control ( W x, Fit-To Wide )

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
ContinueColumnScroll := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
EndUpdate();
with (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('Exontrol.Print'))) as EXPRINTLib_TLB.Print) do
begin
Options := 'FitToPage = 2 x';
PrintExt := (IUnknown(Grid1.DefaultInterface) as EXGRIDLib_TLB.Grid);
Preview();
end;
end
|
926
|
Do you have any Fit-To-Page options when printing the control ( percent view, Adjust-To )

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
ContinueColumnScroll := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
EndUpdate();
with (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('Exontrol.Print'))) as EXPRINTLib_TLB.Print) do
begin
Options := 'FitToPage = 50%';
PrintExt := (IUnknown(Grid1.DefaultInterface) as EXGRIDLib_TLB.Grid);
Preview();
end;
end
|
925
|
How can I get notified once the user expands a column

// LayoutChanged event - Occurs when column's position or column's size is changed.
procedure TForm1.Grid1LayoutChanged(ASender: TObject; );
begin
with Grid1 do
begin
OutputDebugString( 'Column-Expanded' );
OutputDebugString( Columns.Item['C0'].Expanded );
end
end;
with Grid1 do
begin
BeginUpdate();
ShowFocusRect := False;
ColumnAutoResize := False;
DrawGridLines := EXGRIDLib_TLB.exAllLines;
BackColorLevelHeader := BackColor;
with Columns do
begin
with (IUnknown(Add('C0')) as EXGRIDLib_TLB.Column) do
begin
ExpandColumns := '0,1,2';
DisplayExpandButton := True;
end;
Add('C1');
Add('C2');
end;
with Items do
begin
h := AddItem('Cell 0.0');
CellValue[OleVariant(h),OleVariant(1)] := 'Cell 0.1';
CellValue[OleVariant(h),OleVariant(2)] := 'Cell 0.2';
h := AddItem('Cell 1.0');
CellValue[OleVariant(h),OleVariant(1)] := 'Cell 1.1';
CellValue[OleVariant(h),OleVariant(2)] := 'Cell 1.2';
end;
EndUpdate();
end
|
924
|
I am using expandable headers, the question is how I can display the column itself, not just the child columns

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
DrawGridLines := EXGRIDLib_TLB.exAllLines;
BackColorLevelHeader := BackColor;
with Columns do
begin
with (IUnknown(Add('C0')) as EXGRIDLib_TLB.Column) do
begin
ExpandColumns := '0,1,2';
DisplayExpandButton := True;
end;
Add('C1');
Add('C2');
end;
with Items do
begin
h := AddItem('Cell 0.0');
CellValue[OleVariant(h),OleVariant(1)] := 'Cell 0.1';
CellValue[OleVariant(h),OleVariant(2)] := 'Cell 0.2';
h := AddItem('Cell 1.0');
CellValue[OleVariant(h),OleVariant(1)] := 'Cell 1.1';
CellValue[OleVariant(h),OleVariant(2)] := 'Cell 1.2';
end;
EndUpdate();
end
|
923
|
How do I layout expandable columns

with Grid1 do
begin
BeginUpdate();
ColumnAutoResize := False;
DrawGridLines := EXGRIDLib_TLB.exAllLines;
BackColorLevelHeader := BackColor;
with Columns do
begin
with (IUnknown(Add('C0')) as EXGRIDLib_TLB.Column) do
begin
ExpandColumns := '1,2';
DisplayExpandButton := True;
end;
Add('C1');
Add('C2');
Add('C3');
with (IUnknown(Add('C4')) as EXGRIDLib_TLB.Column) do
begin
ExpandColumns := '5,6';
DisplayExpandButton := True;
end;
Add('C5');
with (IUnknown(Add('C6')) as EXGRIDLib_TLB.Column) do
begin
ExpandColumns := '6,7';
DisplayExpandButton := True;
end;
Add('C7');
end;
EndUpdate();
Columns.Item['C4'].Expanded := False;
end
|
922
|
How do I make the control read-only (method 2)

// Edit event - Occurs just before editing the focused cell.
procedure TForm1.Grid1Edit(ASender: TObject; Item : HITEM;ColIndex : Integer;var Cancel : WordBool);
begin
with Grid1 do
begin
Cancel := True;
end
end;
with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('Editor')) as EXGRIDLib_TLB.Column).Editor do
begin
EditType := EXGRIDLib_TLB.CheckListType;
AddItem(1,'One',Null);
AddItem(2,'Two',Null);
end;
with (IUnknown(Columns.Add('Check')) as EXGRIDLib_TLB.Column) do
begin
with Editor do
begin
EditType := EXGRIDLib_TLB.CheckValueType;
Option[EXGRIDLib_TLB.exCheckValue1] := OleVariant(2);
end;
end;
with Items do
begin
CellValue[OleVariant(AddItem(OleVariant(1))),OleVariant(1)] := OleVariant(0);
CellValue[OleVariant(AddItem(OleVariant(2))),OleVariant(1)] := OleVariant(1);
end;
EndUpdate();
end
|
921
|
How do I set a locked check-box

with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('Locked-Check')) as EXGRIDLib_TLB.Column) do
begin
with Editor do
begin
EditType := EXGRIDLib_TLB.CheckValueType;
Option[EXGRIDLib_TLB.exCheckValue1] := OleVariant(2);
Locked := True;
end;
end;
with (IUnknown(Columns.Add('Unlocked-Check')) as EXGRIDLib_TLB.Column) do
begin
with Editor do
begin
EditType := EXGRIDLib_TLB.CheckValueType;
Option[EXGRIDLib_TLB.exCheckValue2] := OleVariant(1);
end;
end;
with Items do
begin
CellValue[OleVariant(AddItem(OleVariant(1))),OleVariant(1)] := OleVariant(0);
CellValue[OleVariant(AddItem(OleVariant(0))),OleVariant(1)] := OleVariant(1);
end;
EndUpdate();
end
|
920
|
Does the title of the cell's tooltip supports HTML format

with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('')) as EXGRIDLib_TLB.Column) do
begin
Caption := '';
HTMLCaption := 'Column';
end;
with Items do
begin
CellToolTip[OleVariant(AddItem('tooltip w/h different title')),OleVariant(0)] := '<c><b><fgcolor=FF0000>Title</fgcolor></b><br>This is bit of text that''s shown when the user hovers the cell. This shows the titl' +
'e centered with a different color.';
end;
EndUpdate();
end
|
919
|
How do I specify a different title for the cell's tooltip

with Grid1 do
begin
BeginUpdate();
with (IUnknown(Columns.Add('')) as EXGRIDLib_TLB.Column) do
begin
Caption := 'This is the title';
HTMLCaption := 'Column';
end;
with Items do
begin
CellToolTip[OleVariant(AddItem('tooltip w/h different title')),OleVariant(0)] := 'This is bit of text that''s shown when the user hovers the cell.';
end;
EndUpdate();
end
|
918
|
The cell's tooltip displays the column's caption in its title. How can I get ride of that

with Grid1 do
begin
BeginUpdate();
with Columns do
begin
Add('C1');
Add('C2');
end;
with Items do
begin
h := AddItem('tooltip w/h caption');
CellToolTip[OleVariant(h),OleVariant(0)] := 'This is bit of text that''s shown when the user hovers the cell. This shows the column''s caption in the title.';
CellValue[OleVariant(h),OleVariant(1)] := 'tooltip no caption';
CellToolTip[OleVariant(h),OleVariant(1)] := 'This is bit of text that''s shown when the user hovers the cell. This shows no column''s caption in the title.';
end;
with Columns.Item['C2'] do
begin
HTMLCaption := Caption;
Caption := '';
end;
EndUpdate();
end
|
917
|
How can I programmatically show the column's filter

// RClick event - Fired when right mouse button is clicked
procedure TForm1.Grid1RClick(ASender: TObject; );
begin
with Grid1 do
begin
i := ItemFromPoint[-1,-1,c,hit];
Columns.Item[OleVariant(c)].ShowFilter('-1,-1,128,128');
end
end;
with Grid1 do
begin
BeginUpdate();
ShowFocusRect := False;
with (IUnknown(Columns.Add('Items ')) as EXGRIDLib_TLB.Column) do
begin
DisplayFilterPattern := False;
FilterList := Integer(EXGRIDLib_TLB.exShowExclude) Or Integer(EXGRIDLib_TLB.exShowFocusItem) Or Integer(EXGRIDLib_TLB.exShowCheckBox);
end;
with Items do
begin
AddItem('Item 1');
AddItem('Item 2');
AddItem('Item 3');
end;
EndUpdate();
end
|
916
|
I want to be able to click on one of the headers, and sort by other column. How can I do that (method 2)

// ColumnClick event - Fired after the user clicks on column's header.
procedure TForm1.Grid1ColumnClick(ASender: TObject; Column : IColumn);
begin
// Column.SortOrder = 1
with Grid1 do
begin
SortOnClick := EXGRIDLib_TLB.exDefaultSort;
Columns.Item['Sort'].SortOrder := EXGRIDLib_TLB.SortAscending;
SortOnClick := EXGRIDLib_TLB.exUserSort;
end
end;
with Grid1 do
begin
BeginUpdate();
SortOnClick := EXGRIDLib_TLB.exUserSort;
Columns.Add('Items');
(IUnknown(Columns.Add('Sort')) as EXGRIDLib_TLB.Column).Visible := False;
with Items do
begin
CellValue[OleVariant(AddItem('Item 1 (3)')),OleVariant(1)] := OleVariant(3);
CellValue[OleVariant(AddItem('Item 2 (1)')),OleVariant(1)] := OleVariant(1);
CellValue[OleVariant(AddItem('Item 3 (2)')),OleVariant(1)] := OleVariant(2);
end;
EndUpdate();
end
|
915
|
I want to be able to click on one of the headers, and sort by other column. How can I do that (method 1)

// ColumnClick event - Fired after the user clicks on column's header.
procedure TForm1.Grid1ColumnClick(ASender: TObject; Column : IColumn);
begin
// Column.SortOrder = 1
with Grid1 do
begin
Items.SortChildren(0,'Sort',True);
end
end;
with Grid1 do
begin
BeginUpdate();
SortOnClick := EXGRIDLib_TLB.exUserSort;
Columns.Add('Items');
(IUnknown(Columns.Add('Sort')) as EXGRIDLib_TLB.Column).Visible := False;
with Items do
begin
CellValue[OleVariant(AddItem('Item 1 (3)')),OleVariant(1)] := OleVariant(3);
CellValue[OleVariant(AddItem('Item 2 (1)')),OleVariant(1)] := OleVariant(1);
CellValue[OleVariant(AddItem('Item 3 (2)')),OleVariant(1)] := OleVariant(2);
end;
EndUpdate();
end
|
914
|
How can I highlight the cell's button with a different appearance, when cursor hovers it

with Grid1 do
begin
BeginUpdate();
VisualAppearance.Add(1,'c:\exontrol\images\normal.ebn');
DefaultItemHeight := 22;
TreeColumnIndex := -1;
SelForeColor := RGB(0,0,0);
SelBackColor := BackColor;
Background[EXGRIDLib_TLB.exCursorHoverCellButton] := $1000000;
with (IUnknown(Columns.Add('Buttons')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasButton] := OleVariant(True);
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
Alignment := EXGRIDLib_TLB.CenterAlignment;
HeaderAlignment := EXGRIDLib_TLB.CenterAlignment;
end;
with Items do
begin
AddItem('Button <b>1</b>');
AddItem('Button <b>2</b>');
AddItem('Button <b>3</b>');
end;
EndUpdate();
end
|
913
|
How can I prevent highlighting the cell's button while cursor hovers it

// AddItem event - Occurs after a new Item has been inserted to Items collection.
procedure TForm1.Grid1AddItem(ASender: TObject; Item : HITEM);
begin
with Grid1 do
begin
with Items do
begin
CellValue[OleVariant(Item),OleVariant(0)] := 'Button <b>A</b>';
CellValue[OleVariant(Item),OleVariant(1)] := 'Button <b>B</b>';
end;
end
end;
with Grid1 do
begin
BeginUpdate();
DefaultItemHeight := 22;
TreeColumnIndex := -1;
SelForeColor := RGB(0,0,0);
SelBackColor := BackColor;
Background[EXGRIDLib_TLB.exCursorHoverCellButton] := $ffffffff;
with (IUnknown(Columns.Add('A')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasButton] := OleVariant(True);
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
Alignment := EXGRIDLib_TLB.CenterAlignment;
HeaderAlignment := EXGRIDLib_TLB.CenterAlignment;
end;
with (IUnknown(Columns.Add('B')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasButton] := OleVariant(True);
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
Alignment := EXGRIDLib_TLB.CenterAlignment;
HeaderAlignment := EXGRIDLib_TLB.CenterAlignment;
end;
(IUnknown(Columns.Add('')) as EXGRIDLib_TLB.Column).Position := 1;
with Items do
begin
CellEnabled[OleVariant(AddItem('')),OleVariant(1)] := False;
AddItem('');
AddItem('');
end;
EndUpdate();
end
|
912
|
How can I change the image of the icon while performing OLE Drag and Drop

// OLEStartDrag event - Occurs when the OLEDrag method is called.
procedure TForm1.Grid1OLEStartDrag(ASender: TObject; Data : IExDataObject;var AllowedEffects : Integer);
begin
// Data.SetData("your data to drag")
with Grid1 do
begin
AllowedEffects := 2;
end
end;
with Grid1 do
begin
BeginUpdate();
OLEDropMode := EXGRIDLib_TLB.exOLEDropManual;
ColumnAutoResize := False;
DefaultItemHeight := 22;
HeaderHeight := DefaultItemHeight;
(IUnknown(Columns.Add('Default')) as EXGRIDLib_TLB.Column).Width := 128;
with Items do
begin
AddItem('Item 1');
AddItem('Item 2');
AddItem('Item 3');
AddItem('Item 4');
AddItem('Item 5');
end;
with VisualAppearance do
begin
Add(1,'gBFLBCJwBAEHhEJAAChABakMACAADACAxRDQNABQKAAzQFAYaBiG6GAAGEaRYgmFgAQhFcZQSKUOQTDKMIziYBYfgkMIgSbJUgDGAkRRdDSOYDmGQYDiCIoRShOMIjHL' +
'UXxtDaIZwhEAoJb+RgAUY/cTzaAEUwHHiTKInaCQIhsC4JUJAdRURQ9EwvCIZBpEWwLChENQwWLCNj2TScBwjCyqbale45ViqdoDU8lORLUi+M4zSBPcZVTRtGShPDBK' +
'TjMLaYgkIIlVpRNa0PC1GTzQ6mazkKQLRADDIDVbAeL3LiMBy9LyLLItQALByua5mWhbcZyBCOPgBTrRb5zO58FjuTK7YLjMB7NrUNYtFaUMy2OpOCADIaecTNcaWLxP' +
'F2MY1HWYxVj2Jw3DuRJonKYB5lKAYkkYdA6hyDIjBkApaFoAAhBMfYxiGNAkFECZnm4YQBgiOgDl2URSE4KAEj2AJKigFgGgGYIIAyPQ6CCRogAAOxhAMSgSDgIRDhYF' +
'oFmGCBmBQOAMjgdgQDsUITEIIg5iISAEmIOBigiJgqgqYhoFyVILyyMgyDmYxDg4rBjgiZg6g0Dh4kiTIMGMKAwmgOQkEkFhGhGZIJAoPoQAyQ4mE6BhlAkRgXhODoZC' +
'0A4Pg6KRmCSFplkkdheDmJYTioVgACOY4uGaDwmgmJhqg8JlWmOGRmGkChyhyZxJAobYbmMI4yHqFQnkmdh+2RYp4DMIZ5gaBohmiCYGB+IJOmoNhtiPXZGG2I1tgyb4' +
'lmgGhmhqJt0Fyb4gk8CtsCiahKhYH4oXiAohiUKpKjaLt+goDJxiyaZqlaNot4OTJx3gKp2iiL5sAsBoov+KgMnOMZrisJpKjLjocnPeBLEaRI0m0SxWkSNBPEoDJ1ja' +
'bJrHaXo35obOZC2OximaOZugsYpi3ga42mKO5vAuRpijsTxqAyd49m8S5mnqPuqFyd4gk+DAGn6QJwEwFp+kAT+BnmQpwgwNwOkPtYsnnrgsFcEpFnGDBnBKRRPiwUwc' +
'kecgMgcIpHGMKQwnuSZygyJ1/HKOgMnyS5zAyRwykycw5g4Eg0jCA57DqTpzkydw+kIDR9AUCY9A2HQXBIUh0g0JRJ5aUxmnQZIPnkUgvDUI5tFcVoPjUOB+A4QBAICA' +
'');
Add(2,'gBFLBCJwBAEHhEJAAChABC8MACAADACAxRDQNABQKAAzQFAYaBiG6GAAGEaRYgmFgAQhFcZQSKUOQTDKMIziaQIRDINQlSTJcQjKKEUQTFiXIyAKKwEgmEQMQiCcbzXI' +
'UBxAAqXZZFUaKAgOMJDTLBAzUTCQbR7HiQYyBeCQOo+VoaSACEIlAZJRjoOo5DJGGQILlQJqyYrpaAxIgkEJuTqGoQaXgle53PJeLpXW5Nez9P7AMBwK7bbaqeTyXa+e' +
'DtJhif4cXjIMhyLI8UxXEKOL7jDSYPgqK48QhCEJQPQ9EyXJqnahoemCeRXBZ+aqxbBsCwCep0YBeNr3HaNaz3PK/brtWxMDpeA5IYhhF7WdZFR4tMrOdAtHL9FyPJ5T' +
'FicgXnoTAKAsRpHPeVhrAUd4LkmY5yj+fQ+i8L4zk+Y5vjCe4oD6ZoNhSRxiisVRKg+T5vnWfB6h6J5yAIf4fieWJFHyHZHHSTAygyAociMKBKEKBIeCiCZyHYFAnCAB' +
'4mBeBQJlgRIegOCgYCySAgh2WAkgINAMmMNIgCcCYoGYLoLmKaIshqCgMliEICgmDRDEiUQmkmAhWDCD5inicIVg4TQYloJg2g2ExYhoJZJEidIThMCQSFyEwkGKaRKF' +
'EJQJBkOhLCUJIDFoRiKBmBJhDeDZZDoPAlgmQhghaGZimmHhphqZopDoYw3GYEgFgGHROGOFJkCSSQCDoTAkiSaQ6C6IBJFkPIUCSJ5CDoeQ5CcVZ5gWHROmONJsCMSI' +
'SByEFyjIRoYiaKYaG6HonEiOhcguJQIHoRJsh0WBWB2JIpiqShKi0OwqnqRouiyTpGhGBxiYIZKOhqGp2j4aRaAqZL3FAECAgA==');
end;
Background[EXGRIDLib_TLB.exDragDropBefore] := $1000000;
Background[EXGRIDLib_TLB.exDragDropAfter] := $2000000;
Background[EXGRIDLib_TLB.exDragDropForeColor] := $10000;
EndUpdate();
end
|
911
|
How can I sort by two-columns, one by date and one by time

with Grid1 do
begin
BeginUpdate();
SingleSort := False;
with Columns do
begin
(IUnknown(Add('Index')) as EXGRIDLib_TLB.Column).FormatColumn := '1 index ``';
(IUnknown(Add('Date')) as EXGRIDLib_TLB.Column).SortType := EXGRIDLib_TLB.SortDate;
with (IUnknown(Add('Time')) as EXGRIDLib_TLB.Column) do
begin
SortType := EXGRIDLib_TLB.SortTime;
FormatColumn := 'time(value)';
end;
end;
with Items do
begin
h := AddItem(OleVariant(0));
CellValue[OleVariant(h),OleVariant(1)] := '1/1/2001';
CellValue[OleVariant(h),OleVariant(2)] := '1/1/2001 10:00:00 AM';
h := AddItem(OleVariant(0));
CellValue[OleVariant(h),OleVariant(1)] := '12/31/2000';
CellValue[OleVariant(h),OleVariant(2)] := '1/1/2001 10:00:00 AM';
h := AddItem(OleVariant(0));
CellValue[OleVariant(h),OleVariant(1)] := '1/1/2001';
CellValue[OleVariant(h),OleVariant(2)] := '1/1/2001 6:00:00 AM';
h := AddItem(OleVariant(0));
CellValue[OleVariant(h),OleVariant(1)] := '12/31/2000';
CellValue[OleVariant(h),OleVariant(2)] := '1/1/2001 8:00:00 AM';
h := AddItem(OleVariant(0));
CellValue[OleVariant(h),OleVariant(1)] := '1/1/2001';
CellValue[OleVariant(h),OleVariant(2)] := '1/1/2001 8:00:00 AM';
h := AddItem(OleVariant(0));
CellValue[OleVariant(h),OleVariant(1)] := '12/31/2000';
CellValue[OleVariant(h),OleVariant(2)] := '1/1/2001 6:00:00 AM';
end;
Layout := 'multiplesort="C1:1 C2:1"';
EndUpdate();
end
|
910
|
How can I display a context menu

// MouseUp event - Occurs when the user releases a mouse button.
procedure TForm1.Grid1MouseUp(ASender: TObject; Button : Smallint;Shift : Smallint;X : Integer;Y : Integer);
begin
with Grid1 do
begin
with (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('Exontrol.ContextMenu'))) as EXCONTEXTMENULib_TLB.ExContextMenu) do
begin
Items.ToString := 'Check[chk],[sep],Item 1,Item 2,Item 3';
OutputDebugString( Select(Null,Null,Null) );
end;
end
end;
with Grid1 do
begin
ColumnAutoResize := False;
ScrollBySingleLine := True;
ContinueColumnScroll := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
ReadOnly := EXGRIDLib_TLB.exReadOnly;
end
|
909
|
Also, are there any plans on the ability to put borders on individual cells or rows or columns

with Grid1 do
begin
BeginUpdate();
with VisualAppearance do
begin
Add(1,'gBFLBCJwBAEHhEJAAChABOUGACAADACAxRDQNABQKAAzQFAYbBkGqGAAGIYxYgmFgAQhFcZQSpEEg7BKMYwjOJgFgmEQxDANIBQSKoaQiGQYRhkEYgEiONoaDJCM4wHI' +
'MQxHCKTZRkGYpajOPobUbGUywHRcRRvH6EZQGWg6GjqK43SCEEZhJBNGyTJ6BZbGURbCqSLAwWZAYy2RCMRxDJqLKypSwKPoGKosS5OUwzHItaRtHaJJAwKZ6ApGQpRV' +
'TAYxVfC1PzkACma4nS7oXraVJFVZTdYwTh+JABTzGLpnKw7FhGa5pABpdq0RTuOZdAbPMoyXBrXqqB46UCOGg5HRWWwHR7ZIquap9JzfCq5cRbWr5BBOPaBYKwdD1CB+' +
'iMVRnlQRY4hafZwAMH5Pl4XQnjCEBECSIBpDGHQOicIwtBIBpmiWEIJj6eJQloEgomafgyGGCI6kKYZQH+igGAKAJgEgFgGgGYIFlCf4CmCSA2A6A5hAgRgEgQYRIFYF' +
'IEmEaBmBmBghigdgQgcIZogYC4ICIKB6CSCRhiiHgogWIooi4F4AmKaIaDCDBihiTg0gsIIYmYOoOmOSJ2D6AZQBAgI=');
Add(2,'gBFLBCJwBAEHhEJAAChABdUIQAAYAQGKIaBoAKBQAGaAoDDYMg1QwAAxDGLEEwsACEIrjKCVIgkHYJRjGEZxNCMIhiGAaQChEZYHgkMomDAOEgyHKcEgJGyEQgkOa4aj' +
'CKYrSzAcrwTI4cRVHiQZygOZ4DBSOY8VBAcQweItJhrKqVRgriitNQjCyjZCpOaIDooAJmRZNNISBBIEQSKA0TDOQ5TSKUMYhOZTBBEbbMNBtBIUIRpajbMBiFywUxUO' +
'JYXhmG4dR7IMhyLI8UxXFo7P7mOZZXjmO49T7Kc70LQ9CyHJKnabpWoaXj2VZZV7Mda2DTNSzPKK1bZpG4bTouKZ5WjfN72fgeCzrF7HchyPJcXxnG4ZAMBA');
Add(3,'gBFLBCJwBAEHhEJAAChABL0GACAADACAxRDQNABQKAAzQFAYbBkGqGAAGIYxYgmFgAQhFcZQSpEEg7BKMYwjOJgEgmEQxDANIBQSKoaQiGQYRhkEYpFiONoXDJCM4wHI' +
'MQxHCKTZRkGYpajOPobUbGUygBRdExvEyEZQGWg6GjqK43SCEEZhJBNGyfH6dBpEWT7ChENQwWLLFoRDIcQyXCytIDter4boGKosS5OUwzGAtaRvHaJJAwKZ6ApGQpRV' +
'TAYxUdC1HTjJiEa4nS7oXraVJFVZTdYwTh+JABTzGKbsSycKqWaqkABZeoWbTuOZdAbPMoyXBrXgOLYzUCOGg5HRWWwHR7ZIq0Pg9Hqaa4bVbIVxbcAGH6BQa6J5hEBE' +
'CSIBpDGHQOicIwtBIBpmhqEIJj2eJQloEgokiegyGGCI6kKZ5BnefA+D8L4flOa52nufg+g+f5fnPFB/ooBZ1omSAWASAJgGgJgJgIIIoDYAIDCCaBFnuBAhCgOgUgUY' +
'IoF4GIBiGKBuAcfohmgNgdggX54g4JB/F+GImCqCpikiNguguUAQICA=');
Add(4,'gBFLBCJwBAEHhEJAAChABBUGACAADACAxRDQNABQKAAzQFAYbBkGqGAAGIYxYgmFgAQhFcZQSpEEg7BKMYwjOJgCgmEQxDANMiwGKoaQiGQYRhkEYgFiONoaDJCM4wHI' +
'MQxHCKTZRkGYpajOPobUbAYQQSAkEgpECbZqoEZaDoaOorTZINJ0VR1Ox5KKfZyGURZPqOEQ1DBZEI2RZUbxDJquLhACj7AjeZZtRJZVp2TY9eQ3LC3aYhGqwAwSFpJV' +
'jUEBgRBJIDSMY6DpOIxaEgNZpwEITOTxUK0EhRLy5agDCJ1QrCdanahqOpaXpmW5dV7YNh2LTnfzXNq3bhuO5bXqOd59X7fN54Dg+D4LRLHbpxXIcXqvFaZZDnOb4ToP' +
'EuAZUmqcB2B2DoHGuN5Tm6d46lsPwfhOS5mnOeg9DqCAIICA');
end;
LinesAtRoot := EXGRIDLib_TLB.exGroupLinesAtRoot;
SelBackColor := BackColor;
SelForeColor := ForeColor;
DefaultItemHeight := 22;
Columns.Add('');
(IUnknown(Columns.Add('')) as EXGRIDLib_TLB.Column).Def[EXGRIDLib_TLB.exCellBackColor] := OleVariant(33554432);
Columns.Add('');
with Items do
begin
h := AddItem('Root 1');
ItemBackColor[h] := $1000000;
hx := SplitCell[OleVariant(h),OleVariant(0)];
CellValue[OleVariant(0),OleVariant(hx)] := 'count(current,dir,1)';
CellValueFormat[OleVariant(0),OleVariant(hx)] := EXGRIDLib_TLB.exTotalField;
FormatCell[OleVariant(0),OleVariant(hx)] := '''Childs: '' + value';
CellBackColor[OleVariant(0),OleVariant(hx)] := $3000000;
CellHAlignment[OleVariant(0),OleVariant(hx)] := EXGRIDLib_TLB.CenterAlignment;
InsertItem(h,Null,'Child 1');
InsertItem(h,Null,'Child 2');
ExpandItem[h] := True;
h := AddItem('Root 2');
ItemBackColor[h] := $4000000;
hx := SplitCell[OleVariant(h),OleVariant(0)];
CellValue[OleVariant(0),OleVariant(hx)] := 'count(current,dir,1)';
CellValueFormat[OleVariant(0),OleVariant(hx)] := EXGRIDLib_TLB.exTotalField;
FormatCell[OleVariant(0),OleVariant(hx)] := '''Childs: '' + value';
CellBackColor[OleVariant(0),OleVariant(hx)] := $3000000;
CellHAlignment[OleVariant(0),OleVariant(hx)] := EXGRIDLib_TLB.CenterAlignment;
InsertItem(h,Null,'Child 1');
InsertItem(h,Null,'Child 2');
InsertItem(h,Null,'Child 3');
ItemBackColor[InsertItem(h,Null,'Child 4')] := $4000000;
end;
EndUpdate();
end
|
908
|
How can I decode the Layout property
with Grid1 do
begin
BeginUpdate();
with Columns do
begin
Add('C1');
(IUnknown(Add('C2')) as EXGRIDLib_TLB.Column).Position := 1;
end;
with Items do
begin
CellValue[OleVariant(AddItem('SubItem 1.1')),OleVariant(1)] := 'SubItem 1.2';
CellValue[OleVariant(AddItem('SubItem 2.1')),OleVariant(1)] := 'SubItem 2.2';
end;
Columns.Item['C2'].SortOrder := EXGRIDLib_TLB.SortDescending;
EndUpdate();
OutputDebugString( 'Encoded:' );
OutputDebugString( Layout );
with (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('Exontrol.Print'))) as EXPRINTLib_TLB.Print) do
begin
OutputDebugString( 'Decoded: ' );
OutputDebugString( Decode64TextW[Grid1.Layout] );
end;
end
|
907
|
No new line is shown if using <br> tag. How can I show a new line with-in the cell

with Grid1 do
begin
BeginUpdate();
ScrollBySingleLine := True;
DrawGridLines := EXGRIDLib_TLB.exRowLines;
with (IUnknown(Columns.Add('Single-Line')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellSingleLine] := OleVariant(True);
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
end;
with (IUnknown(Columns.Add('Multiple-Lines')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellSingleLine] := OleVariant(False);
Def[EXGRIDLib_TLB.exCellValueFormat] := OleVariant(1);
end;
with Items do
begin
CellValue[OleVariant(AddItem('First-Line<br>Second-Line')),OleVariant(1)] := 'First-Line<br>Second-Line';
h := AddItem('First-Line<br>Second-Line<br>Third-Line');
CellSingleLine[OleVariant(h),Null] := EXGRIDLib_TLB.exCaptionWordWrap;
CellHAlignment[OleVariant(h),OleVariant(0)] := EXGRIDLib_TLB.CenterAlignment;
ItemDivider[h] := 0;
end;
EndUpdate();
end
|
906
|
I am using exCRD to layout the columns in the grid, but is there a way where I can have the text in a cell wrap if it's exceeds the width of the cell instead of showing the ...'s

with Grid1 do
begin
BeginUpdate();
DrawGridLines := EXGRIDLib_TLB.exRowLines;
DefaultItemHeight := 36;
FullRowSelect := EXGRIDLib_TLB.exColumnSel;
with Columns do
begin
with (IUnknown(Add('Column1')) as EXGRIDLib_TLB.Column) do
begin
Visible := False;
Editor.EditType := EXGRIDLib_TLB.EditType;
end;
with (IUnknown(Add('Column2')) as EXGRIDLib_TLB.Column) do
begin
Visible := False;
Editor.EditType := EXGRIDLib_TLB.EditType;
end;
with (IUnknown(Add('Column3')) as EXGRIDLib_TLB.Column) do
begin
Visible := False;
Def[EXGRIDLib_TLB.exCellSingleLine] := OleVariant(False);
Editor.EditType := EXGRIDLib_TLB.EditType;
end;
with (IUnknown(Add('Column4')) as EXGRIDLib_TLB.Column) do
begin
Alignment := EXGRIDLib_TLB.CenterAlignment;
HeaderAlignment := EXGRIDLib_TLB.CenterAlignment;
Visible := False;
Def[EXGRIDLib_TLB.exCellHasButton] := OleVariant(True);
Def[EXGRIDLib_TLB.exCellButtonAutoWidth] := OleVariant(True);
end;
with (IUnknown(Add('FormatLevel')) as EXGRIDLib_TLB.Column) do
begin
FormatLevel := '(0/1),"Information to be shown on the control''s header"[a=17][ww]:128,3:128';
Def[EXGRIDLib_TLB.exCellFormatLevel] := '(0/1),2[a=17][ww]:128,3:128';
end;
end;
with Items do
begin
h := AddItem('Cell 1.1');
CellValue[OleVariant(h),OleVariant(1)] := 'Cell 1.2';
CellValue[OleVariant(h),OleVariant(2)] := 'This is just a bit of information on first row';
CellValue[OleVariant(h),OleVariant(3)] := 'Cell 1.4';
CellSingleLine[OleVariant(h),OleVariant(3)] := EXGRIDLib_TLB.exCaptionWordWrap;
h := AddItem('Cell 2.1');
CellValue[OleVariant(h),OleVariant(1)] := 'Cell 2.2';
CellValue[OleVariant(h),OleVariant(2)] := 'This is just a bit of information on second row';
CellValue[OleVariant(h),OleVariant(3)] := 'Cell 2.4';
end;
EndUpdate();
end
|
905
|
How can I load pictures using URL ( http:// )
with Grid1 do
begin
http := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('Exontrol.HTTP'))) as EXHTTPLib_TLB.HTTP);
PictureDisplay := EXGRIDLib_TLB.LowerRight;
Picture := (IUnknown(http.GETImage['http://mail.exontrol.com/images/exontrol.png']) as _TLB.Object);
end
|
904
|
How can I filter programmatically by multiple columns
with Grid1 do
begin
BeginUpdate();
with Columns do
begin
Add('Name');
with (IUnknown(Add('Active')) as EXGRIDLib_TLB.Column) do
begin
Def[EXGRIDLib_TLB.exCellHasCheckBox] := OleVariant(True);
DisplayFilterButton := True;
end;
Add('Type');
(IUnknown(Add('Mode')) as EXGRIDLib_TLB.Column).FilterType := EXGRIDLib_TLB.exFilter;
end;
with Items do
begin
h := AddItem('Item A');
CellState[OleVariant(h),OleVariant(1)] := 1;
CellValue[OleVariant(h),OleVariant(2)] := 'A';
h := AddItem('Item B');
CellState[OleVariant(h),OleVariant(1)] := 0;
CellValue[OleVariant(h),OleVariant(2)] := 'B';
h := AddItem('Item C');
CellState[OleVariant(h),OleVariant(1)] := 1;
CellValue[OleVariant(h),OleVariant(2)] := 'C';
CellValue[OleVariant(h),OleVariant(3)] := 'None';
h := AddItem('Item D');
CellState[OleVariant(h),OleVariant(1)] := 1;
CellValue[OleVariant(h),OleVariant(2)] := 'C';
end;
with Columns.Item[OleVariant(1)] do
begin
FilterType := EXGRIDLib_TLB.exCheck;
Filter := 1;
end;
with Columns.Item[OleVariant(2)] do
begin
FilterType := EXGRIDLib_TLB.exFilter;
Filter := 'C';
end;
with Columns.Item[OleVariant(3)] do
begin
FilterType := EXGRIDLib_TLB.exNonBlanks;
end;
ApplyFilter();
EndUpdate();
end
|
903
|
How can I add Right-To-Left Reading-Order / RTL Layout
with Grid1 do
begin
BeginUpdate();
TreeColumnIndex := -1;
with (IUnknown(Columns.Add('RTL - Header Caption')) as EXGRIDLib_TLB.Column) do
begin
HeaderAlignment := EXGRIDLib_TLB.AlignmentEnum($20000 Or Integer(EXGRIDLib_TLB.RightAlignment));
Alignment := EXGRIDLib_TLB.AlignmentEnum($20000 Or Integer(EXGRIDLib_TLB.RightAlignment));
end;
FullRowSelect := EXGRIDLib_TLB.exColumnSel;
with Items do
begin
AddItem('RTL - Text Right');
CellHAlignment[OleVariant(AddItem('RTL - Text Center')),OleVariant(0)] := EXGRIDLib_TLB.AlignmentEnum($20000 Or Integer(EXGRIDLib_TLB.CenterAlignment));
CellHAlignment[OleVariant(AddItem('RTL - Text Left')),OleVariant(0)] := EXGRIDLib_TLB.AlignmentEnum($20000);
end;
EndUpdate();
end
|
902
|
I have applied ebn to the grid using the following code, and noticed that it applies to the filter dropdownList too. Is there a way to prevent this behavior, like keeping the Filter dropdownlist intact

with Grid1 do
begin
VisualAppearance.Add(1,'c:\exontrol\images\normal.ebn');
Appearance := EXGRIDLib_TLB.AppearanceEnum($1000000);
BackColorHeader := $1000000;
Background[EXGRIDLib_TLB.exBackColorFilter] := $8000000f;
(IUnknown(Columns.Add('Filter')) as EXGRIDLib_TLB.Column).DisplayFilterButton := True;
with Items do
begin
AddItem('Item 1');
AddItem('Item 2');
end;
end
|
901
|
The tree lines from the group parent to its children are missing and no identation is present: the parent and all its children are on the same offset from left. What canbe done

// AddGroupItem event - Occurs after a new Group Item has been inserted to Items collection.
procedure TForm1.Grid1AddGroupItem(ASender: TObject; Item : HITEM);
begin
with Grid1 do
begin
with Items do
begin
nGroupColumn := GroupItem[Item];
ItemDivider[Item] := -1;
FormatCell[OleVariant(Item),OleVariant(0)] := FormatCell[OleVariant(Item),OleVariant(nGroupColumn)];
CellValue[OleVariant(Item),OleVariant(0)] := OleVariant(Grid1.Columns.Item[OleVariant(nGroupColumn)].GroupByTotalField);
CellValueFormat[OleVariant(Item),OleVariant(0)] := CellValueFormat[OleVariant(Item),OleVariant(nGroupColumn)];
end;
end
end;
with Grid1 do
begin
BeginUpdate();
ReadOnly := EXGRIDLib_TLB.exReadOnly;
ColumnAutoResize := False;
rs := (IUnknown(ComObj.CreateComObject(ComObj.ProgIDToClassID('ADOR.Recordset'))) as ADODB_TLB.Recordset);
with rs do
begin
Open('Orders','Provider=Microsoft.ACE.OLEDB.12.0;Data Source=C:\Program Files\Exontrol\ExGrid\Sample\Access\misc.accdb',3,3,Null);
end;
DataSource := (IUnknown(rs) as ADODB_TLB.Recordset);
SortBarVisible := True;
SortBarCaption := 'Drag a <b>column</b> header here to group by that column.';
AllowGroupBy := True;
with Columns.Item[OleVariant(0)] do
begin
AllowGroupBy := False;
Width := 96;
end;
Columns.Item[OleVariant(1)].SortOrder := EXGRIDLib_TLB.SortAscending;
LinesAtRoot := EXGRIDLib_TLB.exLinesAtRoot;
EndUpdate();
end
|